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
相关推荐
FOREVER-Q23 分钟前
Windows 下 Docker Desktop 快速入门与镜像管理
运维·服务器·windows·docker·容器
二进制的Liao28 分钟前
【编程】脚本编写入门:从零到一的自动化之旅
数据库·python·算法·自动化·bash
IT瑞先生1 小时前
Docker容器使用手册——入门篇(上)
运维·docker·容器
青柚~3 小时前
【鲲鹏服务器麒麟系统arm架构部署docker】
服务器·arm开发·docker·架构
喜欢你,还有大家4 小时前
Docker-存储
运维·docker·容器
Lucis__5 小时前
STL设计模式探秘:容器适配器&仿函数
c++·容器·stl·仿函数
人工智能训练6 小时前
Docker中容器的备份方法和步骤
linux·运维·人工智能·ubuntu·docker·容器·nvidia
bing.shao6 小时前
Goer-Docker系列-1-管理工具
docker·容器·eureka
MasonYyp6 小时前
Docker安装和使用kkfileview
运维·docker·容器
王煜苏6 小时前
contos7安装dokcer遇到的坑,docker-composer
docker·eureka·composer