docker ps查看正在运行的容器docker ps -a查看运行过的容器docker pull ubuntu:20.04下载 ubuntu 镜像docker pull myregistry.local:5000/testing/test-image:0.1下载指定域名下的镜像docker run --name test -dit alpine由镜像得到容器(容器在后台运行),并把容器取名为 testdocker run alpine sh由镜像得到容器,并运行 sh 命令(容器在当前终端运行)docker run -p 9090:8080 -dit alpine端口映射docker run -e ENV1=foo -dit alpine设置环境变量docker run --network=xxx -dit alpine设置网络docker stop container_id或docker kill container_id停止容器(二者区别见这里)docker start container_id开始运行容器docker rm container_id删除已停止运行的容器docker rm -f container_id强制删除容器,不管有没有在运行docker rm $(docker ps --filter status=exited -q)删除所有已停止运行的容器docker rmi image_id删除镜像docker system prune删除占用硬盘的垃圾对象,包括没用的 container、images、networkdocker image prune -a删除所有没被用到的镜像