退出代码 0 docker [英] exited with code 0 docker

查看:27
本文介绍了退出代码 0 docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 docker-compose 服务启动容器.但不幸的是,容器退出,代码为 0.容器的构建归功于来自 .tar.gz 存档的存储库.这个档案是一个 Centos 虚拟机.

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.

我想从同一个存档创建 6 个容器.我不想输入 6 次 docker 命令,而是想创建一个 docker-compose.yml 文件,我可以在其中总结他们的命令和标签.

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.

我已经开始编写 docker-compose.yml 文件只是为了创建一个容器.

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

这是我的 docker-compose.yml :

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 ?

感谢您的回复.

推荐答案

答案其实是第一条评论.我会稍微解释一下 Miguel 的评论.

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

首先,我们需要了解 Docker 容器运行单个命令.只要该命令启动的进程正在运行,容器就会运行.一旦进程完成并退出,容器将停止.

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.

有了这样的理解,我们就可以假设您的情况会发生什么.当您启动 dvpt 服务时,它会运行命令 mkdir/root/essai/.该命令创建文件夹,然后退出.此时Docker容器因为进程退出而停止(状态为0,表示mkdir已完成,没有错误).

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).

这篇关于退出代码 0 docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆