[root@host01 ~]# yum makecache [root@host01 ~]# yum install docker [root@host01 ~]# yum install golang
[root@host01 ~]# systemctl enable docker [root@host01 ~]# systemctl start docker [root@host01 ~]# docker version Client: Version: 1.13.1 API version: 1.26 Package version: docker-1.13.1-68.gitdded712.el7.centos.x86_64 Go version: go1.9.4 Git commit: dded712/1.13.1 Built: Tue Jul 17 18:34:48 2018 OS/Arch: linux/amd64 Server: Version: 1.13.1 API version: 1.26 (minimum version 1.12) Package version: docker-1.13.1-68.gitdded712.el7.centos.x86_64 Go version: go1.9.4 Git commit: dded712/1.13.1 Built: Tue Jul 17 18:34:48 2018 OS/Arch: linux/amd64 Experimental: false
Environment="HTTP_PROXY=http://用户名:密码@代理IP:端口" Environment="HTTPS_PROXY=http://用户名:密码@代理IP:端口" Environment="NO_PROXY=localhost,127.0.0.1"
追加代理配置内容到/lib/systemd/system/docker.service中的Environment段的下面linux
[root@host01 ~]# systemctl daemon-reload [root@host01 ~]# systemctl restart docker
[root@host01 ~]# groupadd docker [root@host01 ~]# usermod -aG docker $USER
非root用户执行时,须要建立docker用户组,将当前用户加入docker用户组
[root@host01 ~]# docker run hello-world 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://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
在公司内部进行docker pull时,因为一般要通过代理,有可能会因为证书问题致使镜像没法pull下来,此时须要如下解决方案git
- 获取公司代理的证书(以Chrome为例,打开一个能够打开的外网,打开地址栏的安全按钮,查看证书详细信息,复制证书,采用默认格式导出证书便可。)
- 将证书更名为cacert.pem
- 将cacert.pem放到CentOS的/etc/pki/ca-trust/source/anchors下
- 执行update-ca-trust命令使其生效