The following steps/scripts will build a "snappy" Docker swarm using Ubuntu's Snappy core release.
If being run on a host with a decent number of cores and ram, then start from the beginning and install all of the pieces on that host. Otherwise you can create vm's running snappy which then are added to the swarm.
The
bin/prep-host
script will perform the steps listed below. The steps are listed below with commentary for reference.
This assumes a 64-bit server which is running Ubuntu 14.04. Verify that updates are installed:
sudo apt-get update
sudo apt-get upgrade -y
- Install uv-tool (from directions located at
Snappy Ubuntu Core and uvtool):
sudo apt-add-repository ppa:snappy-dev/tools sudo apt-get update sudo apt-get -y install uvtool
- If you don't have a
~/.ssh/id_rsa.pub
then:ssh-keygen
- Download the images
uvt-simplestreams-libvirt sync --snappy flavor=core release=devel
We want a recent/new version of Docker, so we need to use a different set of repositories than the "default". These instructions follow the Docker on Ubuntu installation instructions.
- Do the "easy" install:
curl -sSL https://get.docker.com/ubuntu/ | sudo sh
- To eliminate the need to
sudo
every time you rundocker
do the following:Note: there is a potential security issue; see Docker Daemon Attack Surface for details.
sudo groupadd docker sudo gpasswd -a ${USER} docker sudo service docker restart
- Modify the Docker start script to bind to a port on the private
network in addition to the file socket:
sudo service docker stop sudo sh -c 'echo DOCKER_OPTS=\"-H tcp://192.168.122.1:4243 -H unix:///var/run/docker.sock\" >> /etc/default/docker' sudo service docker start
- Install the go binaries:
sudo apt-get install -y golang-go golang-go.tools
- Configure the environment. We're going to set up some global
variables and ensure that they're loaded into subsequent shell
sessions:
sudo sh -c "cat > /etc/profile.d/golang-env.sh" <<EOF export GOROOT=/usr/share/go export GOPATH=\${GOROOT} export PATH=\${PATH}:\${GOROOT}/bin EOF . /etc/profile.d/golang-env.sh
We're installing it to the global position; in order to do this we need to "cheat" a little bit & specify an environmental variable to tell it where to install:
sudo GOPATH=$GOPATH go get -u github.com/docker/swarm
Logout and log back in to ensure all the environment settings are captured.
In order to create our swarm, run bin/create-cluster N
where N
is
the number of members in the swarm.
etc/config
is used to override any parameters for the swarm members.
By default a member has the following properties:
Property | Default Value | Notes |
---|---|---|
cpu | 1 | Number of Cores |
memory | 512 | Amount of system RAM in MB |
disk | 8 | Size of the OS disk in GB |
log-console-output | STDOUT | Log output to a disk file on the host instead of STDOUT |
unsafe-caching | false | Do not flush guest syncs to the host on the OS disk. This can improve guest I/O performance at the cost of losing data on host power failure. This option is useful for ephemeral guest machines that do not need to be persistent beyond a host power cycle. |
bridge | none | Replace the first defined NIC with one that connects to the given host bridge. |