标签:gid creat 交互式 epo wait folders cat 强制 exit
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest a55fbf438dfd 8 days ago 95MB mysql latest 7bb2586065cd 8 days ago 477MB nginx latest 2bcb04bdb83f 8 days ago 109MB centos latest 9f38484d220f 2 weeks ago 202MB hello-world latest fce289e99eb9 3 months ago 1.84kB docker run -it 9f38484d220f #启动交互式容器 [root@8e0ffee781f1 /]# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 02:23 pts/0 00:00:00 /bin/bash root 16 1 0 02:23 pts/0 00:00:00 ps -ef [root@8e0ffee781f1 /]# exit exit [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@localhost ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8e0ffee781f1 9f38484d220f "/bin/bash" 4 minutes ago Exited (0) 3 minutes ago pensive_lumiere 3af63c5c69c6 hello-world "/hello" 42 hours ago Exited (0) 42 hours ago pensive_dubinsky [root@localhost ~]# docker rename 8e0ffee781f1 mycentos [root@localhost ~]# docker start mycentos mycentos [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8e0ffee781f1 9f38484d220f "/bin/bash" 40 minutes ago Up 6 seconds mycentos [root@localhost ~]# docker stats mycentos CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS 8e0ffee781f1 mycentos 0.00% 380KiB / 991.2MiB 0.04% 656B / 0B 0B / 0B 1 [root@localhost ~]# docker top mycentos UID PID PPID C STIME TTY TIME CMD root 4675 4659 0 10:44 pts/0 00:00:00 /bin/bash [root@localhost ~]# docker attach mycentos 不关容器,安全退出: ctrl +p ctrl+q [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8e0ffee781f1 9f38484d220f "/bin/bash" 3 hours ago Up 2 hours mycentos [root@localhost ~]# docker images centos REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 9f38484d220f 2 weeks ago 202MB [root@localhost ~]# docker run -it --name mycentos01 centos #重新打开一个容器,并命名为mycentos01 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ed1315df6320 centos "/bin/bash" About a minute ago Up About a minute mycentos01 8e0ffee781f1 9f38484d220f "/bin/bash" 3 hours ago Up 2 hours mycentos
[root@localhost ~]# docker stop mycentos mycentos01 #同时停止多个容器 mycentos mycentos01 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]# docker start mycentos mycentos01 mycentos mycentos01 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ed1315df6320 centos "/bin/bash" 9 minutes ago Up 36 seconds mycentos01 8e0ffee781f1 9f38484d220f "/bin/bash" 3 hours ago Up 36 seconds mycentos
docker rmi 删除镜像
[root@localhost ~]# docker ps -n2 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ed1315df6320 centos "/bin/bash" 23 minutes ago Exited (137) 7 minutes ago mycentos01 8e0ffee781f1 9f38484d220f "/bin/bash" 3 hours ago Exited (137) 8 minutes ago mycentos [root@localhost ~]# docker rm mycentos01 mycentos01 [root@localhost ~]# docker ps -n2 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8e0ffee781f1 9f38484d220f "/bin/bash" 3 hours ago Exited (137) 9 minutes ago mycentos 3af63c5c69c6 hello-world "/hello" 45 hours ago Exited (0) 45 hours ago pensive_dubinsky
[root@localhost ~]# docker run -d --name mycentos1 centos ba18b348bd9857bde9b25a62d848d6239c1c7c0de302a8bc279185a758efd861 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@localhost ~]# docker run -d --name mycentos2 centos /bin/bash -c "while true;do echo Hello World;sleep 3;done" 21494ef841e27c69877afaf1a0be5ae2bb7d32d6862eb7bfa1e6eb237f04efa3 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21494ef841e2 centos "/bin/bash -c ‘while…" 2 seconds ago Up 2 seconds mycentos2 [root@localhost ~]# docker logs -f -t --tail 5 21494ef841e2 2019-04-04T07:37:43.721260403Z Hello World 2019-04-04T07:37:46.721904929Z Hello World 2019-04-04T07:37:49.723204790Z Hello World 2019-04-04T07:37:52.724042843Z Hello World 2019-04-04T07:37:55.725116649Z Hello World ...
[root@localhost ~]# docker run -d centos /bin/bash -c "while true;do echo Nihao;sleep 2 ;done" 4768a70886fcb74cdf00cb19d142fb503a18d2390406dc31ad533d697b423f46 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4768a70886fc centos "/bin/bash -c ‘while…" 3 seconds ago Up 2 seconds affectionate_cori [root@localhost ~]# docker top 4768a70886fc UID PID PPID C STIME TTY TIME CMD root 9379 9364 0 15:48 ? 00:00:00 /bin/bash -c while true;do echo Nihao;sleep 2 ;done root 9427 9379 0 15:48 ? 00:00:00 sleep 2
[root@localhost ~]# docker inspect 4768a70886fc [ { "Id": "4768a70886fcb74cdf00cb19d142fb503a18d2390406dc31ad533d697b423f46", "Created": "2019-04-04T07:48:20.460764642Z", "Path": "/bin/bash", "Args": [ "-c", "while true;do echo Nihao;sleep 2 ;done" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, ....
[root@localhost ~]# docker exec -t -w /tmp -uroot -e LANG=en 4768a70886fc ls ks-script-eC059Y yum.log [root@localhost ~]# docker exec 4768a70886fc ls /tmp ks-script-eC059Y yum.log [root@localhost ~]# docker exec -it 4768a70886fc ls /tmp ks-script-eC059Y yum.log [root@localhost ~]# docker exec -it 4768a70886fc /bin/bash [root@4768a70886fc /]# ls anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
[root@localhost ~]# docker cp anaconda-ks.cfg 4768a70886fc:/home [root@localhost ~]# docker exec 4768a70886fc ls /home anaconda-ks.cfg [root@localhost ~]# docker exec -it 4768a70886fc ls /tmp ks-script-eC059Y yum.log [root@localhost ~]# docker cp 4768a70886fc:/tmp/yum.log /tmp [root@localhost ~]# ls -l /tmp 总用量 8 -rw-------. 1 root root 0 3月 6 01:34 yum.log
标签:gid creat 交互式 epo wait folders cat 强制 exit
原文地址:https://www.cnblogs.com/plluoye/p/10658522.html