安装Docker
安装
[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
配置Docker代理(有条件可选)
Environment="HTTP_PROXY=http://用户名:密码@代理IP:端口"
Environment="HTTPS_PROXY=http://用户名:密码@代理IP:端口"
Environment="NO_PROXY=localhost,127.0.0.1"
追加代理配置内容到/lib/systemd/system/docker.service中的Environment段的下面
重启
[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下来,此时需要以下解决方案
- 获取公司代理的证书(以Chrome为例,打开一个可以打开的外网,打开地址栏的安全按钮,查看证书详细信息,复制证书,采用默认格式导出证书即可。)
- 将证书改名为cacert.pem
- 将cacert.pem放到CentOS的/etc/pki/ca-trust/source/anchors下
- 执行update-ca-trust命令使其生效
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。