Docker daemon config file on boot2docker / docker-machine / Docker Toolbox

瘦欲@ 提交于 2019-11-27 17:36:58

Inside boot2docker (boot2docker ssh) / docker-machine (docker-machine ssh default) , open or create the file /var/lib/boot2docker/profile and add the following line:

EXTRA_ARGS="--dns 192.168.1.145"

Also works for:

EXTRA_ARGS="--insecure-registry myinternaldocker"

After the change you need to restart the docker daemon:

sudo /etc/init.d/docker restart

Or leave boot2docker / docker-machine and restart the entire virtual machine:

boot2docker restart
# for docker machine
docker-machine restart default

Information taken from: https://groups.google.com/d/msg/docker-user/04pAX57WQ7g/_LI-z8iknxYJ

Regards

Gil

It took me quite some time to figure this out. If you are using a mac you have to go to a fresh terminal and run:

boot2docker ssh

This will open a new terminal, from there you have to edit or create a file

sudo vi /var/lib/boot2docker/profile

and add the DNS that you would like to add, for example:

DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4"

After that you need to restart boot2docker. Here I had some issues at the beginning so I close everything and run in a terminal:

boot2docker down
boot2docker up

you can also use:

boot2docker restart

I had to do it twice. After that I started again using the normal boot2docker icon and everything worked.

I hope this helps.

If you want to script things, you can do these steps on one ugly line:

boot2docker ssh 'sudo sh -c "echo \"EXTRA_ARGS=\\\"--dns 1.2.3.4\\\"\" > /var/lib/boot2docker/profile && sudo /etc/init.d/docker restart"'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!