日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

docker代理设置ssl证书_docker - 设置HTTP/HTTPS 代理

發(fā)布時(shí)間:2023/12/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 docker代理设置ssl证书_docker - 设置HTTP/HTTPS 代理 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、設(shè)置代理原因

因公司安全限制,所有外網(wǎng)需配置代理后才可上網(wǎng),但是因?yàn)樗拗鳈C(jī)上設(shè)置過代理,并未太過多注意此問題,之后run時(shí)報(bào)如下錯(cuò)誤:

# docker run hello-world

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

docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).

See 'docker run --help'.

在網(wǎng)上搜索過一番之后,發(fā)現(xiàn):如果在docker 宿主機(jī)上設(shè)置了代理(HTTP、HTTPS)之后,在docker daemon 啟動(dòng)的時(shí)候,也要相應(yīng)的告知 daemon,使用代理來訪問internet!!

2、解決方案

盡管docker daemon 的配置可以兩種方式來實(shí)現(xiàn):

2.1通過daemon.json文件來修改

2.2通過覆蓋docker.service來實(shí)現(xiàn)

但是對(duì)于代理的配置,目前為止(docker 17.06)我們只能使用第二個(gè)方案。 具體的步驟如下:

創(chuàng)建docker.service目錄

mkdir -p /etc/systemd/system/docker.service.d

創(chuàng)建HTTP&HTTPS代理文件

# cat /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]

Environment=HTTP_PROXY=xxx.xxx.xxx.xxx:8080 NO_PROXY=localhost,127.0.0.1

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

[Service]

Environment=HTTPS_PROXY=xxx.xxx.xxx.xxx:8080 NO_PROXY=localhost,127.0.0.1

解析:

主要是兩點(diǎn)內(nèi)容:

① ?HTTPS_PROXY將它的值對(duì)應(yīng)到您所希望設(shè)置的代理服務(wù)地址和端口(例如:?HTTPS_PROXY=https://proxy.example.com:443),我這里為了保護(hù)隱私,就用xxx代替.

② ?NO_PROXY?意味著某些情況下我們不需要使用HTTPS代理來訪問,一般這就配置私有倉庫的路徑(例如:NO_PROXY=localhost,127.0.0.1,mydocker-registry.com:5000)

3、完成修改后保存/刷新

# systemctl daemon-reload

# systemctl restart docker

4、查看修改結(jié)果

# docker run hello-world

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

latest: Pullingfrom library/hello-world

d1725b59e92d: Pull complete

Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788

Status: Downloaded newer imagefor hello-world:latest

Hellofrom Docker!This message shows that your installation appears to be working correctly.

To generatethismessage, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image fromthe Docker Hub.

(amd64)3. The Docker daemon created a new container fromthat 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.

Totrysomething 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/get-started/

5、重新登錄docker hub

docker login -u xxx -p xxx

login Suceeded

可以看到已經(jīng)成功解決問題!

參考自官方文檔:https://docs.docker.com/engine/admin/systemd/

總結(jié)

以上是生活随笔為你收集整理的docker代理设置ssl证书_docker - 设置HTTP/HTTPS 代理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。