Docker分离模式 [英] Docker Detached Mode

查看:142
本文介绍了Docker分离模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Docker世界中,分离模式是什么?我读了这篇文章
链接,但是

What is detached mode in the docker world? I read this article Link, but it does not explain exactly what detached mode mean.

推荐答案

您可以使用 -d 选项。因此,容器启动并在后台运行。这意味着,您可以启动容器,并且可以在启动后使用控制台来执行其他命令。

You can start a docker container in detached mode with a -d option. So the container starts up and run in background. That means, you start up the container and could use the console after startup for other commands.

与分离模式相反的是前台模式。这是默认模式,当不使用 -d 选项时。在这种模式下,用于执行 docker run 的控制台将附加到标准输入,输出和错误。这意味着您的控制台已连接到容器的进程。

The opposite of detached mode is foreground mode. That is the default mode, when -d option is not used. In this mode, the console you are using to execute docker run will be attached to standard input, output and error. That means your console is attached to the container's process.

在分离模式下,您可以使用 docker日志跟踪docker容器的标准输出- f< container_ID>

In detached mode, you can follow the standard output of your docker container with docker logs -f <container_ID>.

只需尝试两个选项。我总是使用分离模式来运行我的容器。我希望我能解释得更清楚。

Just try both options. I always use the detached mode to run my containers. I hope I could explain it a little bit clearer.

这篇关于Docker分离模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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