Docker gunicorn set up

Hi, I am able to built the docker image successfully. When I run the “docker images” it shows me my docker image. After that when I run the command:

docker run --env-file env digital_worlds:v0 sh -c “python makemigrations && python migrate” it gives me the error:

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: “gunicorn”: executable file not found in $PATH: unknown.

Although gunicorn is installed in my requirements.txt file .

Please provide me some help on this .

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
October 23, 2023


The error you’re encountering indicates that the Docker container is unable to find the gunicorn executable in its PATH. To resolve this issue, you can follow these steps:

  1. Check Your Dockerfile: First, make sure that you have correctly installed gunicorn in your Docker image. It should be installed inside the image during the image building process. Ensure that your Dockerfile contains a line to install the required Python packages, including gunicorn, something like this:
# Install Python packages
RUN pip install -r requirements.txt

If this line is missing or gunicorn is not included in your requirements.txt file, add it.

  1. Rebuild the Docker Image: After making sure gunicorn is correctly included, rebuild your Docker image. Run the following command in the directory where your Dockerfile is located:
docker build -t your_image_name:tag .

Replace your_image_name:tag with the actual name and tag you want for your image.

  1. Run the Docker Container: Once the image is rebuilt, try running your container again, making sure to replace "gunicorn ..." with the correct command you want to run. For example:
docker run --env-file env your_image_name:tag sh -c "python makemigrations && python migrate && gunicorn ..."

Replace "gunicorn ..." with the actual command you use to start your Django application with gunicorn.

  1. Check the Container Command: Ensure that the gunicorn command in your Docker container command (CMD or ENTRYPOINT in your Dockerfile) is correctly specified. It should be something like:
CMD ["gunicorn", "your_app.wsgi:application"]

Replace "your_app.wsgi:application" with the correct import path for your Django application’s WSGI file.

  1. Check for PATH Configuration: If gunicorn is installed in a non-standard location or you have specific PATH configurations in your Docker image, make sure that the PATH to gunicorn is correctly set. You can explicitly specify the PATH when running the container like this:
docker run --env-file env your_image_name:tag sh -c "export PATH=$PATH:/path/to/gunicorn && python makemigrations && python migrate && gunicorn ..."

Replace /path/to/gunicorn with the actual path to the gunicorn executable inside your Docker image.

By following these steps, you should be able to resolve the issue and run your Django application with gunicorn in your Docker container. Ensure that your Docker image includes all the necessary dependencies, including gunicorn, for your Django application to run successfully.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel