Docker

From Wildsong
Jump to navigationJump to search

Docker on Bellman

I migrated services into Dockers on Bellman, including UniFi, owncloud, mariadb, and a media server.

Docker as a service

After getting a container running the way I want, I set it to restart after reboots with the "restart" option. You can issue this option as part of the "run" command but if you are testing the container and it's broken it will endlessly crash and restart. Test first, then use update.

docker update --restart always 'CONTAINER'

When I want the container to stop, for example for maintenance or because I don't currently need the service, I do this:

docker update --restart no 'CONTAINER'
docker stop 'CONTAINER'

Issuing 'stop' alone is not enough, if you do that the docker daemon detects the container stopped and just restarts it.

How do you control the order in which the containers restart?

Docker for PostGIS and Geoserver

Docker ArcGIS Enterprise

The Docker project I am working on right now is to put ArcGIS Enterprise into containers. You can find out more in this Github project

General information

Docker is a container platform.

About a month ago you could not find it on docker.com, but that changed. I used to say "go to Github" but now when you check Github you will get information about a new project Moby that I know very little about, so go to the docker.com site and look for the Community edition. For Debian, try https://www.docker.com/docker-debian

Don't set up PostgreSQL in a Docker container for production. Setting up a database in a Docker is not recommended, but it works for what I want to do: allow one or two people to look at and edit spatial data.

I want to try out Solr (and Tomcat) but don't want to go through the whole installation thing, I just want it all running right now. So I am going to cut to the chase and load a pre-built docker.

Running Java servlets can be a pain because of the requirement to set up Tomcat, and often the apps require a specific version of Tomcat and Java. So running the whole thing in Docker should be easier.

I left my notes on ownCloud down below, I wanted to put it on the Synology NAS. It's not a priority right now since I have switched to using Synology Cloud Station.

I also want to set up containers for Geonode and Geoserver. I know how fiddly Geoserver can be (it runs in Tomcat, too) and so I want to isolate it from the Debian host it will run on.

So in preparation for using Docker. I removed PostgreSQL and Tomcat from my host server. Take that!

Development on Mac

Install Docker for Mac (unless your Mac is too old, boo hoo like Stellar) or Kitematic. Kitematic installs VirtualBox. Docker for Mac is lighter weight. If you already use Vagrant (for MySQL for example) then you already need VirtualBox so Kitematic is fine.

Asking to download Kitematic takes me to the Docker Toolbox download page. The Docker Toolbox includes Kitematic. Kitematic installs VirtualBox if you don't already have it.

After installing the prerequisites, the Docker Toolbox installer took me to the Docker warehouse, where I selected the "official" Solr container and started it, all in one go, without actually needing to know anything at all about Docker or Virtualbox. I now have a running Solr instance.

Deployment on Linux

For Debian make sure you are using docker.com docker-ce package not docker-engine

https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-storage-driver-option

I am using btrfs as a compromise for speed and stability

My /etc/docker/daemon.json file om laysan contains this, it works on Ubuntu but not on Debian Jessie

{                                                                               
   "storage-driver":"btrfs",                                                                
   "graph":"/volumes/ssd_machines/docker",                                     
                                                                               
   "dns":["192.168.123.2"],                                                    
   "dns-search":["arcgis.net"]                                                 
}

See https://docs.docker.com/v1.11/engine/reference/commandline/daemon/#daemon-configuration-file

Just a quick test

You should now be able to download and run a pre-built image from the Docker hub, get a shell prompt, and quit. After you exit from the shell, you can see that the container was running with the "docker ps -a" command.

# Download the Ubuntu Server LTS (Long Term Support) release
docker pull ubuntu:16.04
# Run it interactively with a shell prompt, so we can look around
docker run -it ubuntu /bin/bash
root@a6f99cc58685:/# 
docker ps -a
CONTAINER ID    IMAGE    COMMAND       CREATED           STATUS                      PORTS  NAMES
a6f99cc58685    ubuntu   "/bin/bash"   21 seconds ago    Exited (0) 10 seconds ago          furious_kowalevski


Docker Hub

apt-get install docker-engine

Shortcuts

See all images available on this machine:

docker images

See all running containers and get an id:

docker ps

See all containers, running or not:

docker ps -a

Look at a container in detail

docker inspect id

See also /var/lib/docker/containers/id

Docker networking

Check ifconfig docker0 to see what the bridge address is on your docker server then as needed create a route on your router so that traffic can flow from your local computers into the docker instances running on the docker server.

If you have more than one docker server you have to make sure they don't both pick the same network ip range. If routes are already set up in the router docker should be able to find an unused subnet.

docker pull nginx

cd static-html-directory cat <<EOF > nginx.docker FROM nginx COPY static-html-directory /usr/share/nginx/html EOF

Place this file in the same directory as your directory of content ("static-html-directory"), run ., then start your container:

docker run --name some-nginx -d some-content-nginx

Docker Compose

My big problem is the path for a volume has a space in it and it blows Docker Compose out of the water.

/c/Program Files/

It sees two arguments, with the space as a delimiter

I am trying to find out where it's happening in Compose.

I tried all the variations I could think of to quote it.

compose.parallel.feed_queue: Pending: set([])
compose.parallel.parallel_execute_iter: Finished processing: <Service: datastore>
compose.parallel.feed_queue: Pending: set([])
ERROR: for server  Cannot create container for service server: Invalid bind mount spec "39aab1cb131c79756827d7d4c41fb05dde57bd451011592106e0a0db0aeeb708:Files/ESRI/License10.5/sysgen]:rw": Invalid volume destination path: 'Files/ESRI/License10.5/sysgen]' mount path must be absolute.
ERROR: compose.cli.main.main: Encountered errors while bringing up the project.