Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Docker_Opts in centos

Tags:

I need to set docker to listen to tcp://0.0.0.0/4243 on my host machine running amazon linux (centos). All the documentation I have seen has told me to run the following command

echo DOCKER_OPTS="-H=tcp://127.0.0.1:4243" >> /etc/default/docker 

Which will write the correct docker_opts to /etc/default/docker. I've done this, but when I restart docker it does not listen to 127.0.0.1

I can make docker run correctly by typing

sudo /usr/bin/docker -H tcp://0.0.0.0:4243 -d & 

That works, but I want the default option to be listening on tcp://0.0.0.0:4243 without having to specify it every time.

It seems that docker is completely ignoring my /etc/default/docker file so the settings are being ignored. I also tried writing the file to /etc/default/docker.io and /etc/default/docker-io (didn't really expect much to happen)

I need to be able to start docker with just

service docker start 

or it will cause issues in my current deployment playbook.

Any thoughts on what I can do to set DOCKER_OPTS and not have to do it every time I restart docker?

like image 391
Colin Murphy Avatar asked Oct 02 '14 17:10

Colin Murphy


1 Answers

In RHEL7, instead of modifying your docker.service unit file, you can also just edit your /etc/sysconfig/docker file:

# /etc/sysconfig/docker  # Modify these options if you want to change the way the docker daemon runs OPTIONS=--selinux-enabled -H unix:///var/run/docker.sock -H tcp://0.0.0.0:4243 

and then restart your docker service.

To me, this is more reliable than modifying the service script.

like image 181
Fabien Balageas Avatar answered Sep 18 '22 07:09

Fabien Balageas