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
279 views
in Technique[技术] by (71.8m points)

exited with code 0 docker

I'm trying to launch container using docker-compose services.But unfortunetly, container exited whith code 0. Containers is build thanks to a repository which is from a .tar.gz archive. This archive is a Centos VM.

I want to create 6 container from the same archive. Instead of typing 6 times docker command, I would like to create a docker-compose.yml file where i can summarize their command and tag.

I have started to write docker-compose.yml file just for create one container.

Here is my docker-compose.yml :

version: '2'
services:
  dvpt:
   image: compose:test.1
   container_name: cubop1
   command: mkdir /root/essai/
   tty: true

Do not pay attention to the command as I have just to specify one.

So my question is, why the container is exiting ? Is there a another solution to build these container at the same time ?

Thanks for your responses.

question from:https://stackoverflow.com/questions/44884719/exited-with-code-0-docker

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

1 Reply

0 votes
by (71.8m points)

The answer is actually the first comment. I'll explain Miguel's comment a bit.

First, we need to understand that a Docker container runs a single command. The container will be running as long as that process the command started is running. Once the process is completed and exits then the container will stop.

With that understanding, we can make an assumption of what is happening in your case. When you start your dvpt service it runs the command mkdir /root/essai/. That command creates the folder and then exits. At this point, the Docker container is stopped because the process exited (with status 0, indicating that mkdir completed with no error).


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

...