By Rob Augustinus

Amsterdam power outage and some downtime

So there was a massive poweroutage in Amsterdam yesterday which took down my VPS. This meant I had to manually restart the servers (docker containers) running my website. The nginx webserver did come back up automatically with the archlinux image running on the VPS. But since I did not properly configure the backend or document many of the steps I originally made it took me a bit of time to get everything up and running again.

Lessons learnt

I did learn that restarting your docker containers is actually very simple. Simply running

docker restart <container id> 

did the trick. And in case you forgot the id's you can find those by simply running:

docker ps -a

I wrote a not so great Dockerfile

The only problem then was that I apparently provided a database cleanup script as the entry point to my postgresql docker container, dropping all the data for my blog. Thankfully I still have the markdown files in git for all the articles. Yes, I write these articles in the markdown language using Macdown. This makes it easy to write my articles while offline and just post the markdown file to my website.

Then again this website is running on a very unfinished piece of java code that I had not touched for a while I had to check the code to find the url's to the admin pages :-).

Why did I code my own blog again?

Part of setting up this website/blog using my own code is also to understand docker's usecases better and to figure out which parts I do and don't like about it.

Things to come

So what's left is to read the docker documentation and figure out how to automatically restart the containers in case this ever happens again. Another important thing to do first is to fix the restart procedure of my postgresql database container so it does not drop the data. This should not be too hard since I already mounted a host volume to hold the data for the database.

And ofcourse get the code that runs this website and blog to a more mature level. Which is not my top priority since I am working on another project that will get some fulltime attention from the first of March this year. More on that later.

VPS provider

Oh by the way my VPS provider Transip explained why my VPS went down in a long email with followup. Basically the generator failed to start because of a faulty part which was tested ok just three weeks prior. So yeah shit can happen and I would still recommend them.

Taking ages between writing blog articles

Apparently I don't write that often on this blog. As I am currently still freelancing, for nearly three years now, for the municipality of Rotterdam and my daily commute is about 175 miles I don't have too much time to do interestingly enough things to blog about. Enterprise software is not something I like to write about. Which is exactly the reason I'll be doing something different starting March 1st.

Regards, Rob

By Rob Augustinus

running a private docker repo

In case you don’t want to share all of your docker images or not pull every image from the central docker hub you can run your own. Which is incredibly simple.

http://blog.docker.com/2013/07/how-to-use-your-own-registry/ https://github.com/docker/docker-registry

These two links provide all the information needed to easily run your own private registry and how to push and pull your images from and to it.

By Rob Augustinus

serve a single file over http with go

I needed an easy and simple way to host a single file to test an application I am building at the office. Instead of firing up an entire webserver and configuring it I thought I’d have a look at how this can be done using the go programming language.

Obviously this should only be used for testing purposes since it is insecure and probably very buggy, but it served its purpose in my testing scenario.

https://gist.github.com/raugustinus/f638d783c42c6e49a04e

You can simply compile this with the go build command like so :

go build serve.go

By Rob Augustinus

revised docker debian 8 with oracle jdk8u40 and jetty9.2.5

It’s been a while since my first docker post here and I have been quite busy with work and the family life. Today I needed to rebuild my jetty9 docker image so I revised my Dockerfile(s).

Instead of bootstrapping my debian image, I am now using the ‘official’ debian 8 image, which you can simply pull using the docker pull command.

docker pull debian:8

With this image I created the next 'cleaner’ image by just adding the oracle jdk8u40. As you can see I changed the ownership of the jdk directory to the java user & group. It gives a bit of control over who can run java programs.

FROM debian:8
MAINTAINER Your Name, you@example.net
COPY jdk1.8.0_40 /usr/local/jdk1.8.0_40
ENV JAVA_HOME /usr/local/jdk1.8.0_40
ENV PATH $PATH:$JAVA_HOME/bin

RUN useradd java -U -s /bin/false
RUN chown -R java:java /usr/local/jdk1.8.0_40

USER java
CMD ["java", "-version"]

You can build this image with the docker build command.

docker build -t username/debian8-jdk8u40 .

Obviously you run this build command from the directory you created in which you unpacked the 64bit jdk linux release and put the Dockerfile we mentioned above.

The next part is to use this newly created image to build the jetty9 image. To do this I’ve created the following Dockerfile.

FROM username/debian8-jdk8u40
MAINTAINER Your Name, you@example.net
COPY jetty-9.2.5 /usr/local/jetty-9.2.5

USER root

RUN useradd jetty -U -s /bin/false
RUN chown -R jetty:jetty /usr/local/jetty-9.2.5

EXPOSE 8080
USER jetty
WORKDIR /usr/local/jetty-9.2.5

CMD ["java", "-jar", "start.jar"]

The FROM part in this Dockerfile requires the name you provided to the “docker build -t” command for the build of the previous image.

docker build -t username/debian8-jetty9.2.5 .

Now all that’s left is to run the jetty container with the docker run command.

docker run -d -P username/debian8-jetty9.2.5

And validate jetty’s running with the docker ps command : docker ps The docker ps command should show the PORTS something like : 0.0.0.0:49153->8080/tcp. Using a browser you can validate jetty is running by pointing at the ipaddress or hostname of your docker host and providing the portnumber. In the my next blog I’ll update the jetty image to have some (easier) way of deploying war files to your jetty container but for now I’ll leave it at this.

By Rob Augustinus

coreos static ip address in cloud-config

I wanted my coreos vms to run on static ip addresses so I would not have to update my /etc/hosts each time vmware provided another IP address through dhcp. I looked into fixing the vmware dhcpd.conf which I was unable to correctly do since it would not start the dhcp server anymore. Probably due to the hash of the configuration it uses to check againts it’s own database, but that’s just a guess. The other option is to configure a static ip address in the coreos cloud-config file while installing coreos. For this I created a cloud-config file which, besides setting the static ip address, makes the docker remote API listen on tcp port 2375. I use this to test my docker rest client which I am currently developing. It took me a bit off googling before I could find the right parameter, probably my lack of knowledge of systemd units is to blame. But the coreos documentation mentioned something like this :

name: 00-eth0.network

This did not work for me, instead I found this to work :

name: static.network

¡ The cloud-config file is available as a gist on github here : https://gist.github.com/raugustinus/f5ab05b9ad4584b37d61

By Rob Augustinus

docker debian jessie and oracle jdk

I've been hearing a lot about docker for some time. So I took a plunge tonight and dug in. Headed over to https://www.docker.com/ to go through some documentation.

What I wanted is a debian testing (jessie) image with the latest oracle java 8 release on it. A little digging through the documentation pages, which are not really great, not really bad either. It boils down to this :

Get a docker installation in your favourite linux dist (I used a Debian jessie vm on OSX on my macbook pro running in VMWare Fusion)

apt-get install docker.io
git clone https://github.com/docker/docker (get some contrib scripts)
cd docker/contrib
mkimage.sh -t <username>/debian debootstrap –variant=minbase jessie

(creates a base image with debian 8.0) create a directory to hold your new Dockerfile

cd <new directory>

download the oracle jdk (in this case Java SE development kit 8u25) to this directory unpack the jdk package to jdk1.8.0_25 (default with tar zxvf) create a Dockerfile like this :

FROM <username>/debian
MAINTAINER Who Areyou, you@example.com
COPY jdk1.8.0_25 /usr/local/jdk1.8.0_25
CMD ["ls -l /opt"]

Now run

docker build -t jdk8u25

in the directory in which you created the “Dockerfile”. This should build your new image jdk8u25. You can run the image by running the command:

docker run -it jdk8u25 /bin/bash