gpt4 book ai didi

docker - 如何重新启动已停止的docker/whalesay容器?

转载 作者:行者123 更新时间:2023-12-02 21:25:38 24 4
gpt4 key购买 nike

如Mac的Docker入门文档所述。
docker run docker/whalesay cowsay boo
每次运行此命令时,都会创建,运行和停止一个新容器。

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS                         NAMES


0d96e4bd9c14 docker/whalesay "cowsay boo boo" 11 days ago Exited (0) 5 minutes ago high_archimedes
3a079559382e docker/whalesay "cowsay boo" 11 days ago Exited (0) 26 minutes ago boring_ritchie

我怎么不能再创建一个新的docker / whalesay容器,而是重新启动现有的已停止的docker / whalesay容器并得到与以下相同的结果
docker run docker/whalesay cowsay boo


我试过了
docker start 0d96e4bd9c14

结果只显示
0d96e4bd9c14

没有鲸鱼所显示的鲸鱼图像。

谢谢!

回答:

根据里科的答案

“容器第二次启动,但区别在于您没有将stdout视为默认的start”
docker start -a 0d96e4bd9c14

添加-a,那么我可以看到标准输出结果。

最佳答案

容器第二次启动,但不同之处在于您没有将sttout视为start的默认值

例如:

$ docker run docker/whalesay cowsay boo
Unable to find image 'docker/whalesay:latest' locally
latest: Pulling from docker/whalesay
e9e06b06e14c: Pull complete
a82efea989f9: Pull complete
37bea4ee0c81: Pull complete
07f8e8c5e660: Pull complete
676c4a1897e6: Pull complete
5b74edbcaa5b: Pull complete
1722f41ddcb5: Pull complete
99da72cfe067: Pull complete
5d5bd9951e26: Pull complete
fb434121fc77: Already exists
Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Status: Downloaded newer image for docker/whalesay:latest
_____
< boo >
-----
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
$
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3230d1589aed docker/whalesay:latest "cowsay boo" 32 seconds ago Exited (0) 31 seconds ago evil_curie
$ sudo docker start 3230d1589aed
3230d1589aed

现在检查显示 STATUSExited (0) 2 seconds ago:
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3230d1589aed docker/whalesay:latest "cowsay boo" 46 seconds ago Exited (0) 2 seconds ago evil_curie

您可以使用 docker logs查看输出:
$ sudo docker logs 3230d1589aed
_____
< boo >
-----
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
_____
< boo >
-----
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
$

关于docker - 如何重新启动已停止的docker/whalesay容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38887377/

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