在centOS7上安装docker

更新之前需要配置环境变量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.

成功运行!

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值