Installing docker
You need to install docker engine v1.4 as minimum, some distros doesn't come with lates version
You need to install docker engine v1.4 as minimum, some distros doesn't come with lates version
Docker swarm is usde to manage docker cluster through rest api. To install swarm first you need to install golang (min v 1.4.1)
host$ wget https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz
# here you will install go globaly
host$ sudo tar -C /usr/local -xzf go1.5.1.linux-amd64.tar.gz
# or you can install it in user folder
host$ cd ~ && mkdir go
host$ sudo tar -C ~/go -xzf go1.5.1.linux-amd64.tar.gz
host$ vi /etc/profile.d/go.sh
GOROOT=/usr/local/go
export GOROOT
# add go path
host$ export PATH=host$ PATH:/usr/local/go/bin
# or local if you chose install go localy
host$ export PATH=host$ PATH:host$ GOROOT/bin
host$ export GOHOME
host$ go get -u github.com/docker/swarm
#this will install swarm in your home dir ~/go/bin
host$ PATH=host$ PATH:~go/bin
host$ swarm -v
host$ cat /tmp/my_cluster
192.168.1.100:2375
192.168.1.101:2375
192.168.1.102:2375
host$ swarm manage -H 0.0.0.0:4243 file:///tmp/my_cluster & - swarm with all nodes from file
# or you can use etcd or add nodes via cli:
host$ swarm manage -H 0.0.0.0:4243 nodes://192.168.1.101:2375,192.168.1.102:2375,192.168.1.103:2375 &
host$ export DOCKER_HOST
# constraints are two type, standard (values returned by docker info) and custom
host$ docker run -d --name c1 -e constraint:operatingsystem==Deb* nginx
host$ docker run -d --name c1 -e constraint:operatingsystem==Fedor* nginx
# custom constraints (labels, only from docker v1.4)
# add label to docker engine via docker.conf file (DOCKER_OPTS variable) eg --label zone=dmz --label site=london
host$ vi /etc/default/docker
DOCKER_OPST="-H 192.168.1.100:2375 -H unix:///var/run/docker.sock --label zone=dmz --label site=london"
host$ service docker restart
host$ docker info - (run on local node and not swarm, and at the botom you will see labels assigned to host)
# Now schedule container on specific zone/location (this will work via sworm as well)
host$ docker run -d --name london1 -e constraint:site==london -e constraint:zone==dmz
# or you can specify NOT to run on site
host$ docker run -d --name notlondon1 -e constraint:site!=london -constraing:zone!=dmz"
Docker-compose let's you build service chains from docker images:
host$ sudo curl -L https://github.com/docker/compose/releases/download/VERSION_NUM/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
host$ docker-compose --version
Shipyard is Web UI for docker cluster @ Shipyard Project
Shipyard comes with Etcd running as container and it listens on ports 4001 and 7001. To join new docker engine to swarm cluster
issues command bellow:
If you want to delete key, issue the following command:
http://127.0.0.1:4001/v2/keys/
# URL bellow will show all nodes in swarm cluster:
http://127.0.0.1:4001/v2/keys/docker/swarm/nodes/
Here's good article on how to optimize docker images