I never really thought about any other container service or engine than Docker for my container engine provider. I know there are others, but docker is arguably the most popular, the most documented and has the biggest community supporting it.
As the decision had been made, there was no other option than to blow the dust of my other old busted laptop, install the shiny new Ubuntu Xenial 16.04 on it and get cracking!
- Open a terminal and update your repositories
- Ensure that
httpsmethod, and the CA certificates are installed.
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
- Add the new
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
/etc/apt/sources.list.d/docker.listand remove any existing entries.
Add an entry for Xenial:
deb https://apt.dockerproject.org/repo ubuntu-xenial main.
Save the file and update the
$ sudo apt-get update.
APTis pulling from the right repository
$ apt-cache policy docker-engine.
Finally, install Docker
Install it by
$ sudo apt-get install docker-engine, start the docker daemon
$ sudo service docker start and verify that it works
$ sudo docker run hello-world.
Optionally, I would recommend adding your user to the docker group so you don't have to be sudoing all the time :)
$ sudo usermod -aG docker <username>, and log out and in.
In depth information, and how the installation procedure goes for other operating systems, see the official docker documentations here. You could continue with the official Docker documentation and install UFW (uncomplicated firewall) and DNS server for the containers to use, but if you stick with me, we'll head on creating our first two Docker images.
Creating the images
Before we begin, I would recommend reading and going through Docker's official getting started -guide here before jumping in with Docker CLI, even though the basics are pretty basic.
Mumble server is a popular and widely used VOIP service that I personally host for me and my friends mostly for online gaming sessions. Let's start by creating the dockerfile needed for the container creation. Mine looks like this:
Dockerfile syntax reference and a handy bookmark for future en devours: Docker cheat sheet. The important line here is the
ADD. It copies the .ini file to the container to be used by Mumble, so write your Mumble configurations to this file. As good practice, the file to be copied is in the same folder as dockerfile. Otherwise the copy will fail at build.
- Now, let's build the image:
$ docker build -t mumble ..
- Check that the image was created:
$ docker images.
- Spin up the container:
$ docker run -itd mumble.
It should work now... fingers crossed!
Yey, it worked!
Irssi is the client of the future for IRC users!! :P. I just like the feel and style of the shell. Makes my screen look much more "professional" in the eyes of my girlfriend.
I didn't use a dockerfile for irssi, so this is going to be a quick one-liner.
- Pull and run the image with a volume mapping for the container to show irssi where to get the configuration file:
docker run -itd --name irssi-running -v $PWD/:/home/user/.irssi:ro -v /etc/localtime:/etc/localtime:ro irssi.
- I've pre-configured the configuration file that Irssi uses, so the that Irssi logs in to the preferred channels with my preferred nick automatically.
...and watch the magic unfold.
Above examples of image creation were tiny examples in the dialog of containerized apps and in the usage of Docker. But as I'm learning this stuff on the go, simple is good! I did create a public and a private repositories for the images and tag-pushed them to the Docker Hub. You can download the Mumble Server image with the tag: jatula/hattara-murmur:latest and play around! Hit me up on twitter if you've got suggestions or ideas :).
Join me in part 2 as we dive way deeper with Docker, and build app stacks with Docker Compose. I'm going with Compose even though DAB (Docker Application Bundles) was announced at this years DockerCon (Docker DAB). I feel that DAB is a little over my head for now. In the future, I can supposedly convert the docker-compose.yml file in to a DAB file with little to no effort (or so the documentation suggests :P), so no worries.