码迷,mamicode.com
首页 > 其他好文 > 详细

docker配置反向代理

时间:2017-10-25 23:28:21      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:http   docker   proxy   

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   docker   proxy   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!