框架 | Docker | 1.基本使用

2020-11-25  本文已影响0人  ShadowFieldEric
启动容器(交互模式)
$docker run -t -i ubuntu:15.10
root@23d7f0d01a3b:/#pwd
/
root@23d7f0d01a3b:/#exit
exit
$ 
启动容器(后台模式)
$docker run -d ubuntu:15.10 /bin/sh -c "while true; do echo hello world; sleep 1; done"
4461551b253a3f81474d6de59d9aca949cd3d25329a665778b5a46bf85e10a90
$docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
4461551b253a        ubuntu:15.10        "/bin/sh -c 'while t…"   35 seconds ago      Up 34 seconds                           sharp_ptolemy
$docker logs 4461551b253a
hello world
hello world
hello world
...
$docker logs sharp_ptolemy
hello world
hello world
...
$docker stop 4461551b253a
4461551b253a
$docker stop sharp_ptolemy
sharp_ptolemy
$docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
上一篇下一篇

猜你喜欢

热点阅读