简体   繁体   English

docker进程没有在后台运行

[英]docker process not running in background

Im trying to create a ubuntu docker image but the process is not running in the background when I check the process. 我试图创建一个ubuntu docker镜像,但是当我检查进程时,进程没有在后台运行。

Here are the commands 这是命令

PREMs-MacBook-Pro:Documents prem$ docker run ubuntu:16.04 grep -v '^#' /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted

deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted

deb http://archive.ubuntu.com/ubuntu/ xenial universe
deb-src http://archive.ubuntu.com/ubuntu/ xenial universe
deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates universe

deb http://archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates multiverse

deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse


deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted
deb http://security.ubuntu.com/ubuntu/ xenial-security universe
deb-src http://security.ubuntu.com/ubuntu/ xenial-security universe
deb http://security.ubuntu.com/ubuntu/ xenial-security multiverse
PREMs-MacBook-Pro:Documents prem$ docker run ubuntu:16.04 grep -v '^#' /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted

deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted

deb http://archive.ubuntu.com/ubuntu/ xenial universe
deb-src http://archive.ubuntu.com/ubuntu/ xenial universe
deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates universe

deb http://archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates multiverse

deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse


deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted
deb http://security.ubuntu.com/ubuntu/ xenial-security universe
deb-src http://security.ubuntu.com/ubuntu/ xenial-security universe
deb http://security.ubuntu.com/ubuntu/ xenial-security multiverse
PREMs-MacBook-Pro:Documents prem$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

The simple answer is that your container has already exited when you check for running containers ( docker ps ) 简单的答案是,当您检查运行容器时,您的容器已经退出( docker ps

As docker ps -a show all containers: those running and those not running. 作为docker ps -a显示所有容器:正在运行的容器和未运行的容器。

Your command grep does it job, then exits, so the container exits as well. 你的命令grep完成它的工作,然后退出,所以容器也会退出。

-d does not make any difference here because the container lives for a really short period of time. -d在这里没有任何区别,因为容器在很短的时间内存在。 But you can still see it's output using docker logs <container-id> 但是你仍然可以使用docker logs <container-id>看到它的输出


If you wanna inspect an image, just for fun you can: 如果你想检查图像,只是为了好玩,你可以:

docker run -it imagename bash

(Use sh if bash is not available) (如果没有bash,请使用sh

Bear in mind that docker run create a new container, so changes there will be only in that container. 请记住, docker run创建一个新容器,因此只会在该容器中进行更改。 Images are immutable. 图像是不可变的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM