【Docker】Docker容器管理

Docker容器管理
  • 查看容器
# show run container
docker ps
# show last container
docker ps -l
# show all container
docker ps -a
# show container port info
docker port ContainerID
  • 启动容器
# create new container
docker run -i -t ubuntu:16.04 /bin/bash

# start exist container
# Use ContainerID or ContainerName
docker start ContainerID/ContainerName
  • 停止容器
# exit from container(inside)
exit

# stop container(outside)
docker stop ContainerID/ContainerName
  • 退出容器交互式终端(不停止容器)
Ctrl + Q + P
  • 删除容器
# If containter run, stop it first
docker stop ContainerID/ContainerName

# Remove container
docker rm ContainerID/ContainerName
  • 容器端口映射
# hostPort:ContainerPort (Specified Port)
docker run -p 80:80 --name test -i -t ubuntu:16.04 /bin/bash

# contianerPort (Random Port)
docker run -p 80 --name test -i -t ubuntu:16.04 /bin/bash
  • 提交容器(更新或创建新的镜像)
# update Images use Container
docker commit -m="Update Images" -a="linduo" ContainerID/ContainerNameubuntu:16.04
  • 挂载宿主机目录
# 宿主机绝对路径:容器绝对路径
docker run -i -t -v /home/linduo/Work/Test:/home/Test/ ubuntu:16.04 /bin/bash
  • 端口映射
# 查看指定容器端口情况
docker prot xxxx

# 主机端口:容器端口
docker run -p 80:80 --name test -i -t test:v2 /bin/bash


# 随机映射 容器端口80 随机映射到主机端口
docker run -p 80 --name test -i -t test:v2 /bin/bash
Docker系列
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林多

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值