2019-12-18 22:04:25 +08:00
|
|
|
# Docker 安装和使用
|
|
|
|
|
|
|
|
## 安装
|
|
|
|
|
|
|
|
```sh
|
|
|
|
pacman -S docker
|
|
|
|
```
|
|
|
|
|
|
|
|
## 基本使用
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# 运行谋容器
|
|
|
|
docker run <name/id>
|
2019-12-18 22:39:40 +08:00
|
|
|
# 运行谋容器,并将宿主机的/test目录挂载到容器的/soft目录
|
|
|
|
docker run -it -v /test:/soft <name/id> /bin/bash
|
2019-12-18 22:04:25 +08:00
|
|
|
# 查看正在运行的容器
|
|
|
|
docker ps
|
|
|
|
# 进入正在运行的容器
|
|
|
|
docker exec -it <tag name/id> bash
|
2019-12-18 22:39:40 +08:00
|
|
|
# 提交针对谋容器的修改
|
|
|
|
docker commit <id> <name>:<tag>
|
2019-12-18 22:04:25 +08:00
|
|
|
# 退出容器
|
|
|
|
exit
|
|
|
|
```
|
|
|
|
|
|
|
|
### 容器操作
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# 获得容器信息
|
|
|
|
docker container ls -a
|
|
|
|
# 获得容器id
|
|
|
|
docker container ls -a -p
|
|
|
|
# 停止容器
|
|
|
|
docker container stop <container ID>
|
|
|
|
# 删除容器
|
|
|
|
docker container rm <container ID>
|
|
|
|
```
|
|
|
|
|
|
|
|
### 镜像操作
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# 获得镜像信息
|
|
|
|
docker image ls -a
|
|
|
|
# 获得镜像id
|
|
|
|
docker image ls -a -p
|
|
|
|
# 删除镜像
|
|
|
|
docker image rm <image name/id>
|
|
|
|
```
|