docker 安装方式

1、卸载老版本的docker

[root@cdhmaster01 ~]# yum remove docker  docker-common docker-selinux docker-engine
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
No Match for argument: docker
No Match for argument: docker-common
No Match for argument: docker-selinux
No Match for argument: docker-engine
No Packages marked for removal

2、安装依赖

[root@cdhmaster01 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

3、设置yum源

[root@cdhmaster01 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

4、查看docker的版本

[root@cdhmaster01 ~]# yum list docker-ce --showduplicates | sort -r
Failed to set locale, defaulting to C
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Available Packages
 * updates: ap.stykers.moe
 * extras: ap.stykers.moe
 * base: centos.ustc.edu.cn

5、安装docker

[root@cdhmaster01 ~]# yum install docker-ce docker-ce-cli containerd.io

6、启动和查看docker版本

[root@cdhmaster01 ~]# systemctl start docker
[root@cdhmaster01 ~]# docker version
Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:28:55 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:27:34 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

6、docker错误

[root@cdhmaster01 docker]# docker  build -t  davicn:v1.0  .
Sending build context to Docker daemon  205.4MB
Step 1/8 : FROM java:8-jre
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

修改镜像源

[root@cdhmaster01 docker]# vim /etc/docker/daemon.json
{
     
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
[root@cdhmaster01 docker]# vim /etc/docker/daemon.json

7、配置docker的代理(需要代理服务才能上网)
创建文件夹及文件

[root@cdhmaster01 docker]# mkdir -p /etc/systemd/system/docker.service.d
[root@cdhmaster01 docker]# cd /etc/systemd/system/docker.service.d
[root@cdhmaster01 docker.service.d]# ls
[root@cdhmaster01 docker.service.d]# touch http-proxy.conf https-proxy.conf
[root@cdhmaster01 docker.service.d]# ls
http-proxy.conf  https-proxy.conf

增加文件内容

[root@cdhmaster01 docker.service.d]# vim http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://user:[email protected]:8080/"

[root@cdhmaster01 docker.service.d]# vim https-proxy.conf
[Service]
Environment="HTTPS_PROXY=http://user:[email protected]:8080/"

8、刷新并重启docker服务

[root@cdhmaster01 docker]# systemctl daemon-reload
[root@cdhmaster01 docker]# systemctl restart docker

你可能感兴趣的:(docker,docker)