docker使用记录

加载docker镜像

docker load -i [example.tar]

查看docker镜像

docker images

运行docker镜像

docker run --name [container name] -d [image id]

运行镜像并进入容器

docker run -it --name [container name] [image id] /bin/bash

进入运行的docker

docker exec -it [image id] /bin/bash
docker exec -it -u root <container_id_or_name> bash 进入docker容器的root用户

查看run以及stop的容器

docker ps -a

删除run以及stop的容器

docker rm [container id]

关闭run的容器

docker stop [container id]

启动已关闭的容器

docker start [container id]

把docker容器打包成镜像

docker commit [container name] [repo:tag]

把镜像保存为tar包

docker save -o [imageName.tar] [repo:tag]

把Dockerfile构建成为一个新镜像

docker build -t [image_name] [dest_path]

删除镜像

docker rmi [image id]
docker rmi -f [image id] 强制删除

posted @ 2025-07-24 11:28  Desmend  阅读(6)  评论(0)    收藏  举报