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
删除所有没被用到的镜像