首页 > 其他 > 详细

docker配置反向代理

时间:2017-10-25 23:17:26      阅读:447      评论:0      收藏:0      [点我收藏+]

Custom(定制) Docker daemon options

There are a number of ways to configure the daemon flags and environment variables for your Docker daemon. The recommended way is to use the platform-independent daemon.json file, which is located in /etc/docker/ on Linux by default. See Daemon configuration file.


You can configure nearly all daemon configuration options using daemon.json. The following example configures two options. One thing you cannot configure using daemon.json mechanism(配置) is a HTTP proxy.


Runtime directory and storage driver

You may want to control the disk space used for Docker images, containers, and volumes by moving it to a separate(单独) partition(分开).

To accomplish this, set the following flags in the daemon.json file:

{    "graph": "/mnt/docker-data",    "storage-driver": "overlay" }


HTTP/HTTPS proxy

Create a systemd drop-in directory for the docker service:

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


Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:

[Service] Environment="HTTP_PROXY=http://proxy.example.com:80/"


Or, if you are behind an HTTPS proxy server, create a file called /etc/systemd/system/docker.service.d/https-proxy.conf that adds the HTTPS_PROXY environment variable:

[Service] Environment="HTTPS_PROXY=https://proxy.example.com:443/"

If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable

如果您有内部的Docker注册中心,您需要联系而不使用代理,您可以通过noproxy环境变量来指定它们:

Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

Or, if you are behind an HTTPS proxy server:

Environment="HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

Flush changes:

$ sudo systemctl daemon-reload

Restart Docker:

$ sudo systemctl restart docker

Verify that the configuration has been loaded:

$ systemctl show --property=Environment docker Environment=HTTP_PROXY=http://proxy.example.com:80/

Or, if you are behind an HTTPS proxy server:

$ systemctl show --property=Environment docker Environment=HTTPS_PROXY=https://proxy.example.com:443/


本文出自 “11716212” 博客,请务必保留此出处http://11726212.blog.51cto.com/11716212/1976070

docker配置反向代理

原文:http://11726212.blog.51cto.com/11716212/1976070

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!