docker 常用命令速查
启动和关闭docker服务
service docker start
service docker stop
查看当前所有的docker image文件
docker image ls
查看当前所有正在运行的docker container
docker container ls
构建docker image 镜像文件
docker build -t <image_name> .
将docker image文件实例化为docker container容器
docker run -d -p <linux_port>:<image_port> <image_id>
//注意:-d表示允许后台运行,-p表示端口映射
销毁docker container
docker stop <container_id>
进入docker container
docker exec -it <container_id> /bin/sh
将docker container 保存为 docker image文件
docker commit <container_id> <image_name>
将docker image文件导出为tar压缩包
docker save -o <save_path> <image_name>
将tar压缩包加载为image文件
docker load -i <load_path>
从镜像库拉取镜像文件
docker pull <image_name>
删除本地的镜像文件
docker rmi <image_id>
注意:如果有容器依赖于该镜像的话,可以添加-f参数来强制删除
docker rmi -f <image_id>
清理所有的容器:
docker container prune

浙公网安备 33010602011771号