Docker base image feedback 2014-06-29

This post a more a less a "I've tested this, this worked and I use it that way" post since I know that some people that follows what I do are interested by this subject.

This is about a better base image (for ubuntu) for Docker that the official one. The official docker ubuntu image has a series of problem:

  • most annoying one: init doesn't work, this breaks a lot of things and people end up using supervisor to replace it which isn't optimal at all
  • tmux/screen didn't worked
  • a series of small and obscur bugs, things not working
  • basically it wasn't working like a classical ubuntu/debian

As promised by base-image, this image indeed solves all those issues and I've just got the impression of having a plain ubuntu server when using it.

I use this docker for 3 things:

  • prototyping installation
  • working/testing salt states in a clean environment
  • testing stuff that I don't want to install on my computer

Extract from my DockerFile which install salt minion:

FROM phusion/baseimage:0.9.11  # choose your version here (just pick the version number)

MAINTAINER Bill Gates ""

ENV HOME /root
CMD ["/sbin/my_init"]

RUN sed 's/main$/main universe/' -i /etc/apt/sources.list
RUN sed 's/trusty universe/trusty universe multiverse/' -i /etc/apt/sources.list
RUN sed 's/trusty-updates universe/trusty universe multiverse/' -i /etc/apt/sources.lists

# install salt
RUN add-apt-repository -y ppa:saltstack/salt
RUN apt-get update

RUN mkdir /srv/salt -p
RUN mkdir /srv/pillar -p

# my custom renderer for salt because yaml/jinja has way too much overhead to write (
RUN mkdir /srv/salt/_renderers -p
RUN curl "" > /srv/salt/_renderers/
RUN salt-call --local saltutil.sync_renderers

RUN apt-get install -y vim python-software-properties salt-minion python-pip git zsh python-dev screen tmux

# I want to use zsh
RUN sed '1s/bash/zsh/' -i /etc/passwd

# change root password
RUN sed '1s#:[^:]\+:#:put your password string here:#' -i /etc/shadow

# add your stuff here

# clean stuff
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

I've also made 2 zsh function because I'm lazy and that I don't like to remember docker commands:

# my docker image is tagged/named 'proto'

# usage:
# start_proto
# or
# same for start_protoi

# start the container in daemon mod, you'll need to ssh to it after
# (general they have the ip 172.17.0.*, do a nmap -sP 172.17.0.* if you can't find it)
# (or a "docker ps" then "docker info $ID_TAKEN_FROM_PS" | grep IPAddress)
    docker run -t -d $([ "$1" ] && echo $1 || echo proto) /sbin/my_init

# start the container in interactive mode (you'll end up in zsh)
    docker run -t -i $([ "$1" ] && echo $1 || echo proto) /sbin/my_init -- zsh -l

And my zsh completion script (I've just RTFM how to make them, it's super easy, I'm making one for everything now /o):

#compdef start_proto

_arguments "1: :($(docker images | awk '{print $1}' | sed '1d' | grep -v "<none>" | sort | uniq))"


#compdef start_protoi

_arguments "1: :($(docker images | awk '{print $1}' | sed '1d' | grep -v "<none>" | sort | uniq))"

You need to put them in a _start_proto and _start_protoi files somewhere on the path listed by "echo $fpath" (or extend this path: typically 'fpath=(~/.zsh/completion $fpath)' in your ~/.zshrc and make sure to have "autoload -U compinit" and "compinit" in your ~/.zshrc)