一 docker 的安装
1. 依赖包安装
yum install -y yum-utils device-mapper-persistent-data lvm2
2. 添加 yum 源
- yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
- yum-config-manager --enable docker-ce-edge
- # 配置为安装最新版 Docker CE
3. 安装 docker
yum install docker-ce
* 官方为了简化安装流程提供了便捷的安装脚本
- curl -fsSL get.docker.com -o get-docker.sh
- sh get-docker.sh --mirror Aliyun
4. 启动 docker
- systemctl enable docker
- systemctl start docker
5. 建立 docker 用户和组
6. 测试 docker 是否安装完成
- [docker@dockertest ~]$ docker run hello-world
- Unable to find image hello-world:latest locally
- latest: Pulling from library/hello-world
- ca4f61b1923c: Pull complete
- Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
- Status: Downloaded newer image for hello-world:latest
- Hello from Docker!
- This message shows that your installation appears to be working correctly.
- To generate this message, Docker took the following steps:
- 1. The Docker client contacted the Docker daemon.
- 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
- (amd64)
- 3. The Docker daemon created a new container from that image which runs the
- executable that produces the output you are currently reading.
- 4. The Docker daemon streamed that output to the Docker client, which sent it
- to your terminal.
- To try something more ambitious, you can run an Ubuntu container with:
- $ docker run -it ubuntu bash
- Share images, automate workflows, and more with a free Docker ID:
- https://cloud.docker.com/
- For more examples and ideas, visit:
- https://docs.docker.com/engine/userguide/
7. 配置镜像加速器并重启服务
- cat /etc/docker/daemon.json
- {
- "registry-mirrors": [
- "https://registry.docker-cn.com"
- ]
- }
- systemctl daemon-reload
- sudo systemctl restart docker
- # 学习文档地址: https://github.com/yeasy/docker_practice/blob/master/SUMMARY.md
来源: http://www.bubuko.com/infodetail-2526401.html