Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Create docker container from flask request in uWSGI instance

I have a docker container that is setup to perform some given actions with selenium. My goal is to have the docker container be created when a request is received for a certain endpoint created using flask. The flask app has been setup with uWSGI and Nginx using this tut.

When the endpoint receives a request it is suppose to run the bash script ./run.sh:

#!/bin/bash

ID=$1

docker run --rm \
        -v $(pwd)/code:/code \
        -v /etc/hosts:/etc/hosts \
        selenium \
        python3 \
        /code/main.py ${ID}

I can successfully make a call to the endpoint using the IP given from digital ocean but when it gets to the point where it needs to run docker it says:

docker: command not found

Note, I can go into the virtualenv manually, run python app.py, send request to flask endpoint and the docker container is created and everything works great.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You probably need to add a PATH variable to your bash script which includes the location of your docker executable. The user running NGINX likely doesn't have a path set.

PATH=$PATH:/usr/local/bin:/usr/bin

Also you'll need to ensure that the user running NGINX has permission to use docker, so add them to the docker group.

If this is a public service, then I would think carefully about whether you really want internet users to be launching containers on your server, does $1 come from user input?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!