1、安装 : yum install docker
[root@promote ~]# yum install docker Loaded plugins: fastestmirror docker-main | 2.9 kB 00:00:00 Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package docker.x86_64 2:1.12.5-14.el7.centos will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================================================== Installing: docker x86_64 2:1.12.5-14.el7.centos extras 20 M Transaction Summary =================================================================================================================================================================== Install 1 Package Total download size: 20 M Installed size: 83 M Is this ok [y/d/N]: y Downloading packages: docker-1.12.5-14.el7.centos.x86_64.rpm | 20 MB 00:00:08 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 2:docker-1.12.5-14.el7.centos.x86_64 1/1 Verifying : 2:docker-1.12.5-14.el7.centos.x86_64 1/1 Installed: docker.x86_64 2:1.12.5-14.el7.centos Complete!
2、配置自启动
[root@promote ~]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@promote ~]# systemctl start docker [root@promote ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2017-02-02 08:30:05 CST; 4s ago Docs: http://docs.docker.com Main PID: 22641 (dockerd-current) CGroup: /system.slice/docker.service ├─22641 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cg... └─22648 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-int... Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.079964360+08:00" level=info msg="Graph migration to content-add...econds" Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.080718646+08:00" level=warning msg="mountpoint for pids not found" Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.081060264+08:00" level=info msg="Loading containers: start." Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.100128510+08:00" level=info msg="Firewalld running: true" Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.532830499+08:00" level=info msg="Default bridge (docker0) is as...ddress" Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.777223094+08:00" level=info msg="Loading containers: done." Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.777334646+08:00" level=info msg="Daemon has completed initialization" Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.777357242+08:00" level=info msg="Docker daemon" commit="047e51b...=1.12.5 Feb 02 08:30:05 promote.cache-dns.local dockerd-current[22641]: time="2017-02-02T08:30:05.795410780+08:00" level=info msg="API listen on /var/run/docker.sock" Feb 02 08:30:05 promote.cache-dns.local systemd[1]: Started Docker Application Container Engine. Hint: Some lines were ellipsized, use -l to show in full.
3、测试是否安装成功
[root@promote ~]# docker run hello-world Unable to find image ‘hello-world:latest‘ locally Trying to pull repository docker.io/library/hello-world ... latest: Pulling from docker.io/library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 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. 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/
4、配置阿里容器加速镜像
参考:https://cr.console.aliyun.com/?spm=5176.1971733.2.28.t2Sukx#/accelerator
原文:http://www.cnblogs.com/txk1452/p/6361613.html