{"action":"opened","issue":{"url":"https://api.github.com/repos/phusion/baseimage-docker/issues/227","labels_url":"https://api.github.com/repos/phusion/baseimage-docker/issues/227/labels{/name}","comments_url":"https://api.github.com/repos/phusion/baseimage-docker/issues/227/comments","events_url":"https://api.github.com/repos/phusion/baseimage-docker/issues/227/events","html_url":"https://github.com/phusion/baseimage-docker/issues/227","id":86770341,"number":227,"title":"Restarting a container makes runit freak out","user":{"login":"kstenerud","id":245857,"avatar_url":"https://avatars.githubusercontent.com/u/245857?v=3","gravatar_id":"","url":"https://api.github.com/users/kstenerud","html_url":"https://github.com/kstenerud","followers_url":"https://api.github.com/users/kstenerud/followers","following_url":"https://api.github.com/users/kstenerud/following{/other_user}","gists_url":"https://api.github.com/users/kstenerud/gists{/gist_id}","starred_url":"https://api.github.com/users/kstenerud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kstenerud/subscriptions","organizations_url":"https://api.github.com/users/kstenerud/orgs","repos_url":"https://api.github.com/users/kstenerud/repos","events_url":"https://api.github.com/users/kstenerud/events{/privacy}","received_events_url":"https://api.github.com/users/kstenerud/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-09T23:38:17Z","updated_at":"2015-06-09T23:38:17Z","closed_at":null,"body":"I've made a squid Dockerfile that works well, except when it gets stopped and restarted.\r\n\r\nDockerfile:\r\n\r\n\tFROM phusion/baseimage:0.9.16\r\n\r\n\tRUN apt-get update && \\\r\n\t    apt-get install -y squid3 && \\\r\n\t    mv /etc/squid3/squid.conf /etc/squid3/squid.conf.dist && \\\r\n\t    rm -rf /var/lib/apt/lists/*\r\n\r\n\tCOPY squid.conf /etc/squid3/squid.conf\r\n\tCOPY squid_passwd /etc/squid3/squid_passwd\r\n\r\n\tRUN /usr/sbin/squid3 -N -f /etc/squid3/squid.conf -z\r\n\r\n\tRUN mkdir /etc/service/squid\r\n\tADD squid.sh /etc/service/squid/run\r\n\r\n\tEXPOSE 3128\r\n\r\nMy run script (squid.sh):\r\n\r\n\t#!/bin/sh\r\n\t# `/sbin/setuser memcache` runs the given command as the user `memcache`.\r\n\t# If you omit that part, the command will be run as root.\r\n\texec /usr/sbin/squid3 -NY -d 1 -f /etc/squid3/squid.conf >>/var/log/squid.log 2>&1\r\n\r\nWhen I run it the first time, everything is great. If I stop and restart it, there's a high chance it will get confused.\r\n\r\nOn the first start, the following processes are running:\r\n\r\n    # ps ax\r\n    PID TTY      STAT   TIME COMMAND\r\n      1 ?        Ss     0:00 /usr/bin/python3 -u /sbin/my_init\r\n      8 ?        S      0:00 /usr/bin/runsvdir -P /etc/service\r\n      9 ?        Ss     0:00 runsv squid\r\n     10 ?        Ss     0:00 runsv cron\r\n     11 ?        Ss     0:00 runsv syslog-forwarder\r\n     12 ?        Ss     0:00 runsv sshd\r\n     13 ?        Ss     0:00 runsv syslog-ng\r\n     14 ?        S      0:00 syslog-ng -F -p /var/run/syslog-ng.pid --no-caps\r\n     15 ?        S      0:00 /usr/sbin/cron -f\r\n     16 ?        S      0:00 tail -f -n 0 /var/log/syslog\r\n     17 ?        S      0:00 /usr/sbin/squid3 -NY -d 1 -f /etc/squid3/squid.conf\r\n     22 ?        Ss     0:00 (logfile-daemon) /var/log/squid3/access.log\r\n     23 ?        Ss     0:00 (pinger)\r\n     24 ?        Ss     0:00 bash\r\n     38 ?        R+     0:00 ps ax\r\n\r\nIf I stop and restart the container, it may or may not restart squid. Sometimes it works:\r\n\r\n    # ps ax\r\n    PID TTY      STAT   TIME COMMAND\r\n      1 ?        Ss     0:00 /usr/bin/python3 -u /sbin/my_init\r\n      8 ?        S      0:00 /usr/bin/runsvdir -P /etc/service\r\n      9 ?        Ss     0:00 runsv syslog-ng\r\n     10 ?        Ss     0:00 runsv cron\r\n     11 ?        Ss     0:00 runsv syslog-forwarder\r\n     12 ?        Ss     0:00 runsv sshd\r\n     13 ?        Ss     0:00 runsv squid\r\n     14 ?        S      0:00 syslog-ng -F -p /var/run/syslog-ng.pid --no-caps\r\n     16 ?        S      0:00 /usr/sbin/cron -f\r\n     18 ?        S      0:00 tail -f -n 0 /var/log/syslog\r\n     21 ?        S      0:00 /usr/sbin/squid3 -NY -d 1 -f /etc/squid3/squid.conf\r\n     22 ?        Ss     0:00 (logfile-daemon) /var/log/squid3/access.log\r\n     23 ?        Ss     0:00 (pinger)\r\n     24 ?        Ss     0:00 bash\r\n     38 ?        R+     0:00 ps ax\r\n\r\nSometimes it doesn't:\r\n\r\n    # ps ax\r\n    PID TTY      STAT   TIME COMMAND\r\n      1 ?        Ss     0:00 /usr/bin/python3 -u /sbin/my_init\r\n      7 ?        S      0:00 /usr/bin/runsvdir -P /etc/service\r\n      8 ?        Ss     0:00 runsv syslog-ng\r\n      9 ?        Ss     0:00 runsv cron\r\n     10 ?        Ss     0:00 runsv syslog-forwarder\r\n     11 ?        Ss     0:00 runsv sshd\r\n     12 ?        Ss     0:00 runsv squid\r\n     14 ?        S      0:00 syslog-ng -F -p /var/run/syslog-ng.pid --no-caps\r\n     15 ?        S      0:00 /usr/sbin/cron -f\r\n     16 ?        S      0:00 tail -f -n 0 /var/log/syslog\r\n     29 ?        Ss     0:00 bash\r\n     45 ?        R+     0:00 ps ax\r\n\r\nWhen this happens, you'll see the following in /var/log/squid.log (redirect from the shell script):\r\n\r\n    2015/06/09 23:29:06| Squid is already running!  Process ID 15\r\n    2015/06/09 23:29:07| Squid is already running!  Process ID 15\r\n    2015/06/09 23:29:08| Squid is already running!  Process ID 15\r\n\r\n... Which of course makes no sense since PID 15 isn't even squid3, and never was.\r\n\r\nKilling PID 15 manually fixes the problem (temporarily):\r\n\r\n    # kill 15\r\n    # ps ax\r\n    PID TTY      STAT   TIME COMMAND\r\n      1 ?        Ss     0:00 /usr/bin/python3 -u /sbin/my_init\r\n      7 ?        S      0:00 /usr/bin/runsvdir -P /etc/service\r\n      8 ?        Ss     0:00 runsv syslog-ng\r\n      9 ?        Ss     0:00 runsv cron\r\n     10 ?        Ss     0:00 runsv syslog-forwarder\r\n     11 ?        Ss     0:00 runsv sshd\r\n     12 ?        Ss     0:01 runsv squid\r\n     14 ?        S      0:00 syslog-ng -F -p /var/run/syslog-ng.pid --no-caps\r\n     16 ?        S      0:00 tail -f -n 0 /var/log/syslog\r\n     29 ?        Ss     0:00 bash\r\n    346 ?        S      0:00 /usr/sbin/cron -f\r\n    347 ?        S      0:00 /usr/sbin/squid3 -NY -d 1 -f /etc/squid3/squid.conf\r\n    348 ?        Ss     0:00 (logfile-daemon) /var/log/squid3/access.log\r\n    349 ?        Ss     0:00 (pinger)\r\n    350 ?        R+     0:00 ps ax\r\n"}}