Answer by jkix for Why docker container exits immediately
If you're using docker compose, you can put tty: true in your compose.yml as an argument under a given service:services: ubuntu_test: container_name: dev build: context: . tty: trueSee this answer for...
View ArticleAnswer by ychz for Why docker container exits immediately
docker logs information is not usually helpful to me. Sometimes app's log is same as docker logs output, sometimes is not.docker inspect not helpful in most case either, unless it is a very obvious...
View ArticleAnswer by Richi RM for Why docker container exits immediately
$ docker run -di imageIt works.
View ArticleAnswer by kta for Why docker container exits immediately
Docker container terminates immediately when it did not have any foreground process that helps to connect to user terminal. For example, there is no web server up running in that container.There are...
View ArticleAnswer by questionto42 for Why docker container exits immediately
If you need to just have a container running without exiting, just rundocker run -dit --name MY_CONTAINER MY_IMAGE:latestand thendocker exec -it MY_CONTAINER /bin/bashand you will be in the bash shell...
View ArticleAnswer by Vivek for Why docker container exits immediately
You need to run it with -d flag to leave it running as daemon in the background. docker run -d -it ubuntu bash
View ArticleAnswer by tripleee for Why docker container exits immediately
Coming from duplicates, I don't see any answer here which addresses the very common antipattern of running your main workload as a background job, and then wondering why Docker exits.In simple terms,...
View ArticleAnswer by Jaydeep Ranipa for Why docker container exits immediately
I added read shell statement at the end. This keeps the main process of the container - startup shell script - running.
View ArticleAnswer by xavierbaez for Why docker container exits immediately
If you check Dockerfile from containers, for examplefballiano/magento2-apache-phpyou'll see that at the end of his file he adds the following command:while true; do sleep 1; doneNow, what I recommend,...
View ArticleAnswer by Kert Kukk for Why docker container exits immediately
Add this to the end of Dockerfile:CMD tail -f /dev/nullSample Docker file:FROM ubuntu:16.04# other commandsCMD tail -f /dev/nullReference
View ArticleAnswer by RJFalconer for Why docker container exits immediately
Why docker container exits immediately?If you want to force the image to hang around (in order to debug something or examine state of the file system) you can override the entry point to change it to a...
View ArticleAnswer by Sibeesh Venu for Why docker container exits immediately
There are many possible ways to cause a docker to exit immediately. For me, it was the problem with my Dockerfile. There was a bug in that file. I had ENTRYPOINT ["dotnet", "M4Movie_Api.dll] instead of...
View ArticleAnswer by Adam k for Why docker container exits immediately
Adding exec "$@"at the end of my shell script was my fix!
View ArticleAnswer by Thiago Ramos for Why docker container exits immediately
whenever I want a container to stay up after finish the script execution I add && tail -f /dev/nullat the end of command. So it should be:/usr/local/start-all.sh && tail -f /dev/null
View ArticleAnswer by Leon for Why docker container exits immediately
My pracitce is in the Dockerfile start a shell which will not exit immediately CMD [ "sh", "-c", "service ssh start; bash"], then run docker run -dit image_name. This way the (ssh) service and...
View ArticleAnswer by Brian Olsen for Why docker container exits immediately
A nice approach would be to start up your processes and services running them in the background and use the wait [n ...] command at the end of your script. In bash, the wait command forces the current...
View ArticleAnswer by dskow for Why docker container exits immediately
Since the image is a linux, one thing to check is to make sure any shell scripts used in the container have unix line endings. If they have a ^M at the end then they are windows line endings. One way...
View ArticleAnswer by Krishna Gupta for Why docker container exits immediately
I would like to extend or dare I say, improve answer mentioned by camposerWhen you run docker run -dit ubuntuyou are basically running the container in background in interactive mode.When you attach...
View ArticleAnswer by camposer for Why docker container exits immediately
This did the trick for me:docker run -dit ubuntuAfter it, I checked for the processes running using:docker ps -aFor attaching again the containerdocker attach CONTAINER_NAMETIP: For exiting without...
View ArticleAnswer by Adrian Mouat for Why docker container exits immediately
A docker container exits when its main process finishes. In this case it will exit when your start-all.sh script ends. I don't know enough about hadoop to tell you how to do it in this case, but you...
View Article
More Pages to Explore .....