Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

Created docker container not running bash

I have a docker container that is not running bash. My docker command to create container was:

docker run -it -d -p 8088:80 containername centos:centos6

Which pulls docker image centos6 from hub. Then run docker start containername and returns the name of the container, which is on this example, containername.

If I do docker exec -it containername bash it says Container xxxxxx is not running, When I check on my docker app, it is shaded grey. Rerun docker start containername then docker ps -a it says Container exited 1 second ago.

I read somewhere that the -d (detached mode) will keep the container running but in this case, it does not. This docker run was already used on my computer but I had to reformat due to circumstances. Any help would be appreciated.

question from:https://stackoverflow.com/questions/66060579/created-docker-container-not-running-bash

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your container runs all commands and stop his life. Try to create a Dockerfile with a sleep to keep it alive, like this:

FROM centos:centos6

CMD sleep infinity


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...