Accessing docker host from (jenkins) docker container

我与影子孤独终老i 提交于 2019-12-01 10:37:47

As @ISanych suggests you can simply do -v /var/run/docker.sock:/var/run/docker.sock and it will also magically work on boot2docker. No need to define DOCKER_URL.

You might also find --net=host useful if need to access the ports of the started containers.

I ran into exact same problem with my Jenkins docker plugin. Docker uses tls by default but docker plugin only supports http. What I did is disabling TLS verification on the docker machine. My docker machine is an Ubuntu so the docker conf file is under /etc/default/docker. Inside the conf file, you can disable TLS by adding

--tls=false 

in DOCKER_OPTS. Something like:

DOCKER_OPTS='-H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --tls=false'

This should probably be a comment on the previous answer, but that does not seem possible. This is just a note to remind folks that listening on 0.0.0.0 means listening on whatever publicly routable interfaces might be connected to any physical or virtual network interface configured on your system. Prudence suggests limiting your exposure to only an internal network, less likely to encounter hostile forces with ill intent.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!