Docker笔记¶
基本概念¶
- 镜像 Image 通过运行 Image 来启动 Container。
- 容器 Container Image 的运行时实体。
常用操作¶
管理本机镜像¶
docker info显示详细的 Docker 安装信息docker ps显示正在运行的容器;若要显示已经停止的容器,使用docker ps --all-q或--quiet安静模式显示docker run IMAGE运行容器-d --detach-p host-port:container-port--name given-name-e ENV_VAR=value
docker container ls是docker ps的同义词docker kill终止运行中的容器docker container stop是docker kill的同义词docker container rm <container-name>移除容器docker exec -ti <container-name> bashShell
镜像仓库¶
docker search <image-name>搜索镜像docker pull <iamge-name>拉取镜像
测试Docker是否正常安装¶
docker run hello-world
DockerFile¶
Dockerfile 用于定义容器,通过 docker build 来生成对应 dockerfile 的镜像。
安装docker¶
yum install docker
systemctl start docker