Docker

From wiki.kungfootek.net
Jump to: navigation, search

Docker set up and install between multiple hosts. References on the bottom of this wiki page.

For simplicity there is an assumption of two hosts but there can certainly be more than one remote host. More on this later.


Install Docker on Both hosts:

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io

Edit the remote docker service to listen on the IP instead of the socket. ( Do this on every remote server you desire to connect to )

systemctl edit docker
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://<ip>:2375

Restart the Docker daemon and test for the prescense of port 2375.

netstat -lnputo:

Firewall rules for the remote host:

firewall-cmd --add-port=2375/tcp --add-port=4789/udp --add-port=7946/tcp --add-port=7946/udp --permanent
systemctl restart firewalld

From the calling host:

Place the following into your .bashrc and source it.

export DOCKER_HOST="tcp://0.0.0.0:2375"

Or use:

docker -H tcp://<ip>:2375 <Commands>

Don't forget to make sure the daemons restart on bootup!



Reference for each component mentioned above:


Install on Both hosts:

https://docs.docker.com/install/linux/docker-ce/centos/

Remote Daemon Config:

https://docs.docker.com/install/linux/linux-postinstall/

Calling Host Syntax and config:

https://docs.docker.com/engine/reference/commandline/dockerd/

Firewalld Ports to open:

https://stackoverflow.com/questions/37312055/can-firewalld-work-with-the-docker-overlay-network


Todo: Ansible Playbook that turns any Centos / RHEL box into a remote Docker Daemon