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
相关推荐
无序的浪10 小时前
测试博客-基于微服务的在线判题系统
java·spring cloud·docker·微服务·测试·在线判题
LBL122013 小时前
内网容器部署FTP日志监控服务
运维·服务器·容器
溜达的大象15 小时前
极空间部署Traggo时间追踪工具:Docker安装、标签管理与cpolar远程访问
运维·docker·容器
脏脏a15 小时前
极空间部署 Dashlet:Docker 搭建私人导航仪表盘,再配置固定公网访问
运维·docker·容器
User_芊芊君子16 小时前
Prometheus接入Pushgateway实战:二进制与Docker部署、指标推送及远程上报
docker·容器·prometheus
databook16 小时前
手把手带你走一遍:机器学习模型如何用FastAPI和Docker部署
python·docker·fastapi
江湖有缘17 小时前
3款开源日记工具整理合集,可Docker一键部署!
docker·容器·开源
树下水月21 小时前
linux 系统一键巡检sh
bash
穷人小水滴1 天前
用容器编译 VirtualBox 虚拟机软件 (ArchLinux, podman)
linux·容器·virtualbox
EatFans1 天前
Docker 实战部署:从本地镜像到云服务器,一篇走通 FastAPI + Celery + MySQL + Redis + Nginx
docker·fastapi