Home > Software engineering >  Docker container fails to initalize from docker-compose
Docker container fails to initalize from docker-compose

Time:12-27

Jus new to Dockers and in the process of learning docker-compose. Using Centos8. Created a dir and all files within the directory will have 755 as the permissions. Creating files:

  1. Webapp.py The webapp.py file

  2. requirements.txt requirements.txt file

  3. Dockerfile Dockerfile - contents image

  4. docker-compose.yml

docker-compose.yml - file contents

However, when I start the docker-compose up, it fails by exiting the webapp. Any insights pls, the failure is as below:

webapp keeps exiting

CodePudding user response:

can you trying adding following to your web: after ports:? if stdin_open doesn't work, try stdin

stdin_open: true
tty: true

CodePudding user response:

The docker image shuts down as soon as it finishes running the command CMD["python", "webapp.py"] To keep the container running add the below line in your Dockerfile

ENTRYPOINT ["tail", "-f", "/dev/null"]
  • Related