您的位置:首页 > 运维架构 > Docker

在centOS7上安装docker

2017-01-03 10:46 411 查看
更新之前需要配置环境变量http_proxy

   Vim /etc/profile ,添加

export http_proxy=http://proxy-prc.intel.com:911

 export https_proxy=https://proxy-prc.intel.com:911

source /etc/profile

[root@localhost ~]# yum update

[root@localhost ~]# systemctl enable docker.service

 [root@localhost ~]#systemctl start docker

[root@localhost ~]# docker run --rm hello-world

Unable to find image 'hello-world:latest' locally

Pulling repository docker.io/library/hello-world

docker: Network timed out while trying to connect tohttps://index.docker.io/v1/repositories/library/hello-world/images. You maywant to check your internet connection or if you are behind a proxy..

See 'docker run --help'.

查看失败原因

[root@localhost ~]# env|grep http

http_proxy=http://proxy-prc.intel.com:911

https_proxy=https://proxy-prc.intel.com:911

[root@localhost ~]# curl -v https://index.docker.io/v1/repositories/library/hello-world/images

* About to connect() to proxy proxy-prc.intel.com port 911(#0)

*   Trying10.240.252.20...

* Connected to proxy-prc.intel.com (10.240.252.20) port 911(#0) //说明不是代理问题

* Establish HTTP proxy tunnel to index.docker.io:443

> CONNECT index.docker.io:443 HTTP/1.1

> Host: index.docker.io:443

> User-Agent: curl/7.29.0

> Proxy-Connection: Keep-Alive



< HTTP/1.1 200 Connection established



* Proxy replied OK to CONNECT request

http没有问题,但是系统文件代理没有设置

 [root@localhost ~]#mkdir /etc/systemd/system/docker.service.d

 [root@localhost ~]#vim /etc/systemd/system/docker.service.d/http-proxy.conf

[root@localhost ~]# cat/etc/systemd/system/docker.service.d/http-proxy.conf

[Service]

Environment="http_proxy=http://proxy-prc.intel.com:911"

[root@localhost ~]# systemctl daemon-reload

[root@localhost ~]# systemctl restart docker

[root@localhost ~]# systemctl show docker --propertyEnvironment

Environment=http_proxy=http://proxy-prc.intel.com:911

[root@localhost ~]# docker run --rm hello-world

Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

c04b14da8d14: Pull complete

Digest:sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9

Status: Downloaded newer image for hello-world:latest

 

Hello from Docker!

This message shows that your installation appears to beworking correctly.

成功运行!

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: