Container cannot connect to Upstart #1024

Closed
FooBarWidget opened this Issue Jun 25, 2013 · 14 comments

Projects

None yet
@FooBarWidget

Because Docker replaces the default /sbin/init with its own, there's no way to run the Upstart init inside a Docker container. However this causes some problems: some Debian packages try to communicate with Upstart, and will fail to install if this fails. For example the "at" package.

$ sudo apt-get install at
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  default-mta mail-transport-agent
The following NEW packages will be installed:
  at
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 37.4 kB of archives.
After this operation, 188 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ quantal/main at amd64 3.1.13-2ubuntu1 [37.4 kB]
Fetched 37.4 kB in 0s (75.2 kB/s)
Selecting previously unselected package at.
(Reading database ... 23544 files and directories currently installed.)
Unpacking at (from .../at_3.1.13-2ubuntu1_amd64.deb) ...
Processing triggers for ureadahead ...
Setting up at (3.1.13-2ubuntu1) ...
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
invoke-rc.d: initscript atd, action "start" failed.
dpkg: error processing at (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for ureadahead ...
Errors were encountered while processing:
 at
E: Sub-process /usr/bin/dpkg returned an error code (1)
@creack
Contributor
creack commented Jun 26, 2013

You can workaround this by doing:

dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
@shykes
Contributor
shykes commented Jun 26, 2013

These are actually 2 separate issues:

  1. You're right, 'docker run IMG /sbin/init' doesn't work right now, and it
    should. This will be fixed in pull request #898.
  2. Regardless of that issue, you should not rely on upstart running in the
    background during your build - it won't, since docker only runs one process
    at a time. When apt-get is running, upstart is not. Some ubuntu packages
    expect upstart to be running, and fails if it isn't - this is an annoying
    behavior of the ubuntu packaging system, but it is what it is. This can be
    fixed with the workaround described by Guillaume above.

On Tue, Jun 25, 2013 at 5:18 PM, Guillaume J. Charmes <
notifications@github.com> wrote:

You can workaround this by doing:
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl


Reply to this email directly or view it on GitHubhttps://github.com/dotcloud/docker/issues/1024#issuecomment-20018600
.

@FooBarWidget

Alright, using the trick given by @creack solved my problem.

@foxx
foxx commented Dec 11, 2013

Same problem here, I can confirm that the workaround from @creack worked fine, though it feels a bit hacky

@kiorky
Contributor
kiorky commented Dec 11, 2013

you may have a look to #2276.

@sameersbn sameersbn added a commit to sameersbn/docker-gitlab that referenced this issue Apr 1, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 de3f608
@sameersbn sameersbn added a commit to sameersbn/docker-gitlab-ci-runner that referenced this issue Apr 2, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 bc043ed
@sameersbn sameersbn added a commit to sameersbn/docker-nginx that referenced this issue Apr 2, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 0ae4d9b
@sameersbn sameersbn added a commit to sameersbn/docker-redmine that referenced this issue Apr 2, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 6dfee33
@sameersbn sameersbn added a commit to sameersbn/docker-ubuntu that referenced this issue Apr 2, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 9871718
@sameersbn sameersbn added a commit to sameersbn/docker-gitlab-ci that referenced this issue Apr 11, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 2283309
@sameersbn sameersbn added a commit to sameersbn/docker-gitlab-ci-runner that referenced this issue Apr 11, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 4f6e851
@sameersbn sameersbn added a commit to sameersbn/docker-gitlab that referenced this issue Apr 11, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 dc631c8
@sameersbn sameersbn added a commit to sameersbn/docker-redmine that referenced this issue Apr 14, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 3f00c62
@sameersbn sameersbn added a commit to sameersbn/docker-bind that referenced this issue Apr 14, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 171d47a
@sameersbn sameersbn added a commit to sameersbn/docker-openfire that referenced this issue May 20, 2014
@sameersbn sameersbn build: apply upstart fix from docker/docker#1024 b7a6c20
@vplessi
vplessi commented Sep 3, 2014

Hello, I'm having the same problem.

I am running an Ubuntu 14.04 Virtual Machine, and inside that I installed Docker. I hit the issue with the start command failing to connect to upstart. I tried the above workaround from Decker console but no luck, the second command is failing (also tried to force it with -sf or -sfn flag but even though no error on console, no real effect in solving the issue):

root@c396577:/# dpkg-divert --local --rename --add /sbin/initctl
Leaving 'local diversion of /sbin/initctl to /sbin/initctl.distrib'

root@c396577:/# ln -s /bin/true /sbin/initctl
ln: failed to create symbolic link '/sbin/initctl': File exists

Any hint?

Thansk!

@sameersbn

@vplessi try ln -sf /bin/true /sbin/initctl

@vplessi
vplessi commented Sep 3, 2014

@sameersbn I tried that -sf flag already, check my previous message! The command does not give an error on console, but still the issue with Upstart is there and my processes do not start.

@jeckhart

@vplessi Are you sure you tried ln -sf ? According to your previous comment you only tried -s (the -f tells it to overwrite the target)

@mickhrmweb mickhrmweb added a commit to mickhrmweb/docker-vagrant-ubuntu-upstart that referenced this issue Feb 5, 2015
@mickhrmweb mickhrmweb Added workaround from docker/docker#1024. 2cd5b26
@Layke
Layke commented Jun 20, 2015

So I was able on a Ubuntu distro to run the commands above as a work around, so now my machine will provision correctly the first time. However, now I can't login and see my desktop environment on the machine. Using VirtualBox as the provider and Ubuntu as the distro. Do I need to unlink the symbolic link after successfully loading or just restore the debian package to it's previous value (not sure how to do that also, so commands would be nice, please =D )?

@Layke
Layke commented Jun 20, 2015

OK, actually spent an hour looking into it after all, and it seem like just reinstalling the upstart service fixes not being able to see my desktop environment anymore.

 sudo apt-get --reinstall install upstart

I had been trying this way to avoid reinstalling that package. Can anyone tell me what I"m doing wrong here?

 sudo dpkg-diver --local --remove /sbin/initctl
 sudo rm /sbin/initctl
@swatiswjain

Is there an equivalent of this in RHEL. I am facing a similar issue when creating Chef Server docker image but I couldn't find dpkg-diver --local --remove /sbin/initctl equivalent for RHEL that works

@amaltson

I've got the exact same problem as @swatiswjain with a Chef Server inside Docker.

@ArtificialTruth

@Layke
Probably not useful now, but maybe it's

sudo dpkg-divert --local --remove /sbin/initctl

Instead?

EDIT: What I did which made by server boot:

sudo dpkg-divert --local --rename --remove /sbin/initctl

Not sure if the rename is needed.
Then I did:

sudo ln -s /sbin/initctl.distrib /sbin/initctl

Thanks to: https://www.nesono.com/node/368#comment-551780052

@RdeWilde RdeWilde added a commit to RdeWilde/electrum-ion-release that referenced this issue Dec 24, 2016
@RdeWilde RdeWilde Try to fix upstart error c559d87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment