Monday, December 25, 2017

docker enabling remote daemon administration

one can use the -H option

https://docs.docker.com/engine/reference/commandline/dockerd/#examples
https://docs.docker.com/engine/admin/systemd/#start-automatically-at-system-boot
https://docs.docker.com/engine/reference/commandline/dockerd//#daemon-configuration-file

don't try to use /etc/docker/daemon.json , it's not supported for this option

Do this:

sudo less /usr/lib/systemd/system/docker.service

change
ExecStart=/usr/bin/dockerd
into
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375

systemctl daemon-reload
systemctl restart docker
netstat -an | grep 2375


Now you can connect remotely (in this case I am using localhost, but you can use an IP or a hostname if remotely connecting):

docker -H localhost:2375 info


I have tried with
export DOCKER_HOST="tcp://0.0.0.0:2375"
systemctl daemon-reload
systemctl restart docker


but it didn't work for me...


This allows to do cool stuff like:

curl http://localhost:2375/images/json | python -mjson.tool




No comments: