Thursday, 9 July 2015

"Docker is managed via upstart, try using service docker restart" - baffling advice ?


Presumably every docker user has already followed this advice and experienced a baffling message "unkown job docker". There are quite a lot of questions and some bug reports in the net, but seemingly no satisfying answers. The question seems to me: "What is upstart?" Here is my own workaround.
In place of many questions I refer to   Docker Daemon on Ubuntu In place of some bug reports I refer to unable to restart containers There even exists a recommendation to download upstart

The command man -k upstart gives you some hints and man -s5 init shows you where to dig deeper and find your workaround. In the /etc/init/docker.conf  the  first 2 lines are

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]


The meaning is clear: at boot time the /usr/bin/docker -d is started. Whenever you want to kill the process, it is restarted immediately, because it is only stopped at runlevel 1 or 6.

This is OK for business as usual, but extremely annoying during developing and testing, particularly when there are several processes running the docker daemon, e.g. one started at boot time and another one later by Vagrant's docker provider. After stopping Vagrant, I could not get rid of the process. So I commented the first two lines and had my peace.

Beware: the docker daemon obeys only to his master's voice, which is root. To avoid the eternal sudoing, here is what you can do as experienced user. (Click on the pictures to enlarge.)

Start/Stop docker
 It is informative to look at the messages:


docker messages
Do not forget to inform your colleagues and to uncomment the above-mentioned lines when you finish developing / testing.







No comments: