gpt4 book ai didi

docker进程未在后台运行

转载 作者:行者123 更新时间:2023-12-02 20:14:50 24 4
gpt4 key购买 nike

我试图创建一个 ubuntu docker 镜像,但是当我检查进程时,该进程没有在后台运行。

这是命令

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

最佳答案

简单的答案是,当您检查正在运行的容器时,您的容器已经退出 (docker ps)

docker ps -a显示所有容器:运行的和未运行的。

您的命令grep它工作,然后退出,所以容器也退出。
-d在这里没有任何区别,因为容器的生命周期很短。但是你仍然可以使用 docker logs <container-id> 看到它的输出。

如果您想检查图像,只是为了好玩,您可以:

docker run -it imagename bash

(如果 bash 不可用,请使用 sh)

请记住 docker run创建一个新容器,因此更改只会在该容器中。图像是不可变的。

关于docker进程未在后台运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44267299/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com