parent
ab7cc1e471
commit
5e9168e1af
|
@ -90,7 +90,7 @@ docker pull <name>[:tag]
|
|||
# 运行某镜像并为之创建容器
|
||||
docker run <image name/id>
|
||||
# 运行某镜像,为之创建容器,将宿主机端口影射到容器端口,并将宿主机的某目录挂载到容器的对应目录下
|
||||
docker run -it -p <host ip:port><container port> -v <host dir>:<container dir> <image name/id> /bin/bash
|
||||
docker run -it -p <host ip:port>:<container port> -v <host dir>:<container dir> <image name/id> /bin/bash
|
||||
# 运行某镜像,为之创建容器,随机映射主机端口和容器端口,指定容器名称,赋予 privileged 权限,并将宿主机的某目录挂载到容器的对应目录下
|
||||
docker run -it -P --name=<a container name> --privileged -v <host dir>:<container dir> <image name/id> /bin/bash
|
||||
# 运行某镜像,为之创建容器,设置网络参数,并将宿主机的某目录挂载到容器的对应目录下
|
||||
|
@ -104,13 +104,13 @@ exit
|
|||
# 查看正在运行的容器
|
||||
docker ps
|
||||
# 提交针对某容器的修改,将其保存为镜像
|
||||
docker commit <container id> <repository>:<tag>
|
||||
docker commit <container name/id> <repository>:<tag>
|
||||
# 运行某已存在的容器
|
||||
docker start <container id>
|
||||
docker start <container name/id>
|
||||
# 连接到已运行的容器上
|
||||
docker attach <container id>
|
||||
docker attach <container name/id>
|
||||
# 运行并连接到已存在的容器上
|
||||
docker start -a <container id>
|
||||
docker start -a <container name/id>
|
||||
# 在某已运行的容器中执行命令
|
||||
docker exec -it <container name/id> <cmd and args>
|
||||
# 迁移镜像
|
||||
|
@ -131,11 +131,19 @@ docker container ls -a
|
|||
# 获得容器id
|
||||
docker container ls -a -p
|
||||
# 停止容器
|
||||
docker container stop <container id>
|
||||
docker container stop <container name/id>
|
||||
# 删除容器
|
||||
docker container rm <container id>
|
||||
docker container rm <container name/id>
|
||||
# 重命名容器
|
||||
docker container rename <current name> <new name>
|
||||
# 更新容器的环境变量
|
||||
docker container update --env <MY_VAR>=<value> <container name/id>
|
||||
# 更新容器的端口映射
|
||||
docker container update --publish <host port>:<container port> <container name/id>
|
||||
# 更新容器的内存限制
|
||||
docker container update --memory 512m <container name/id>
|
||||
# 更新容器的 CPU 共享限制
|
||||
docker container update --cpu-shares 512 <container name/id>
|
||||
```
|
||||
|
||||
### 4.2. 镜像操作
|
||||
|
|
Loading…
Reference in New Issue