Question

Docker container not running

Posted December 25, 2020 4.1k views
NginxDockerUbuntu 18.04Flask

I’m following this Dockerized Flask App guide with success!

https://www.digitalocean.com/community/tutorials/how-to-build-and-deploy-a-flask-application-using-docker-on-ubuntu-18-04

I am now adapting my own code, and started with two small changes of setting the base image to FROM python:3.7.3-stretch and adding opencv-python==4.4.0.42 as a requirement (I did this as a docker image on my own local machine successfully). On the Droplet, I see that the container is being successfully created but won’t continue to run even though it’s being invoked with a -d argument. Here’s the output:

#docker images
REPOSITORY                   TAG                   IMAGE ID            CREATED             SIZE
nlp.test                     latest                226105eb5bb1        20 minutes ago      1.23GB

root@NLP-FlaskApp-docker-ubuntu-s-1vcpu-2gb-nyc1-01:/var/www/nlpApp# docker run -d -p 56734:80 --name=nlp.test -v $PWD:/app nlp.test
bcb213b1c1ce5e40f29092f0afbcf6b5e1fa1b76e7922a548af806cd9e43dfec
root@NLP-FlaskApp-docker-ubuntu-s-1vcpu-2gb-nyc1-01:/var/www/nlpApp# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

So nothing shows up as running after the command. I also tried running the same command with different port numbers that I checked are open as well as using the start.sh file given in the guide above.

Please let me know of any debug ideas! Thanks

edited by bobbyiliev
1 comment
  • Ok, I’ve isolated the issue to the base image used. I changed it back from python-stretch to FROM tiangolo/uwsgi-nginx-flask:python3.6-alpine3.7 and now it continues to stay up after running the start.sh script.

    FYI here’s the contents of start.sh:

    #!/bin/bash
    app="app.test"
    docker build -t ${app} .
    docker run -d -p 56736:80 \
      --name=${app} \
      -v $PWD:/app ${app}
    
    edited by bobbyiliev

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.

×
Submit an Answer
2 answers

Hi there @frankieguz,

Usually in such cases, what I could suggest is to add the -a argument to the docker ps -a command. That way you will see all of the containers and not just the running ones.

That way you can grab the container ID of the crashing container and check the logs with the docker logs container_id command to get more information on what’s wrong.

Hope that this helps!
Regards,
Bobby

The issue is using Alpine linux, it seems to be incompatible with opencv-python as a requirement.

Also you can’t simply change base images because the one in the guide provides functionality of uwsgi and Nginx