Docker 中一些常用的容器操作命令,我们可以根据需要使用这些命令来管理和操作 Docker 容器。我们这次以Hell-world这个镜像为例来说明:
- docker pull hello-world #拉取hell-world镜像

- docker images # 查看本地拉取的镜像

- docker run hello-world #运行 hello-world 容器, 后面加参数【-d】一直保持其运行状态。
如:docker run -d hello-world

- docker run -d --restart always hello-world #持续运行hello-world这个容器

- docker ps #查看运行中的容器

-
docker pause 容器名|容器id #暂停运行中的容器
-
docker unpause 容器名|容器id 恢复运行中的容器
-
docker stop 容器名|容器id # 停止运行容器

- docker start 容器名|容器id 开始运行容器

-
docker exec -i 路径 命令 #在容器内执行命令
-
docker rm容器名|容器id 删除运行中的容器

- docker tag hello-world zen_kepler # 为接取的镜像起一个别名:zen_kepler
值得一提的是,如果上述命令无法运行,可能是权限不够,可以在命令前添加sudo, 如:sudo docker ps