docker基本维护命令

docker search centos ##查服务器上面的镜像;
docker images ##查本地的镜像。
docker pull centos ##拉镜像。

docker run centos /bin/echo 'Hello world' ##
docker run -d --name mycentos1 centos ##后台运行镜像名为centos,容器名为testcentos的容器
docker stop testcentos1 ##停止运行容器testcentos1
docker start testcentos1 ##运行已存在的容器testcentos1


docker run --name testcentos -it centos /bin/bash ##镜像名为centos的testcentos容器运行你指定的程序/bin/bash
##进入已运行的容器。

docker container prune #删除所有不运行的容器
docker rmi $(docker images -q) # ##删除所有的镜像

docker stop $(docker ps -q) && docker rm $(docker ps -aq) ##删除所有的容器

docker inspect --format "{{.State.Pid}}" registry ##获得容器名为registry的pid

##进入容器的脚本

#!/bin/bash
Cname=$1
Cpid=$(docker inspect --format "{{.State.Pid}}" ${Cname})
nsenter --target ${Cpid} --mount --uts --ipc --net --pid

原文地址:https://www.cnblogs.com/liulvzhong/p/11516982.html