docker使用教学

docker使用教学

启动容器

shell 复制代码
docker run -d -p 80:80 --name nginx1 nginx 
docker run -d -p 8080:80 nginx #进行端口映射时,宿主机的一个端口只能被一个容器使用
docker run -p 81:80 nginx

停止容器

shell 复制代码
docker stop <container_name> #比较温和的停止容器的方式,会给容器进行退出工作时间

杀死容器

shell 复制代码
docker kill <container_name> #比较强硬的停止容器的方式,不会给容器进行退出工作时间

删除容器

shell 复制代码
docker rm <container_name>

挂载卷

shell 复制代码
docker run -d -p 8080:80 -v ./data:/data nginx

在容器中执行命令

shell 复制代码
docker exec <container_name> <command>
docker exec -it <container_name> /bin/sh

快速删除容器

shell 复制代码
docker ps -q | xargs docker kill
docker ps -aq | xargs docker rm

查看容器

shell 复制代码
docker ps

查看所有容器

shell 复制代码
docker ps -a

查看镜像

shell 复制代码
docker images

导出镜像

shell 复制代码
docker save -o <image-name>.tar <image-name>

导入镜像

shell 复制代码
docker load -i <image-name>.tar
相关推荐
weixin_462446239 小时前
使用 Python 脚本自动化管理 Docker 容器:启动、修改密码、删除及系统资源监控
python·docker·自动化·系统监控
溜达的大象10 小时前
Navidrome 打造专属无损音乐库,加载cpolar局域网外访问也能超丝滑
阿里云·docker·云原生·eureka
gjxDaniel10 小时前
Bash编程语言入门与常见问题
开发语言·bash
Wpa.wk11 小时前
Docker容器 - 了解Docker基础命令(容器+镜像命令)
运维·经验分享·测试工具·docker·容器
步菲12 小时前
Windows系统安装Docker Desktop配置daemon.json不生效问题解决
windows·docker·容器
sxy_976113 小时前
AX86u官方固件温度监控(CPU,WIFI芯片)
python·docker·curl·nc·nas·温度·ax86u
optimistic_chen13 小时前
【Docker入门】Docker Registry(镜像仓库)
linux·运维·服务器·docker·容器·镜像仓库·空间隔离
木卫二号Coding13 小时前
Docker-构建自己的Web-Linux系统-镜像kasmweb/ubuntu-jammy-desktop
linux·ubuntu·docker
加油vekiki13 小时前
linux服务器搭建docker、docker-compose
linux·服务器·docker·容器
迎仔14 小时前
CSI (Container Storage Interface) 通俗原理解析:K8s 的“万能存储插头”
云原生·容器·kubernetes