Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running services (upstart/init.d) in a container

I'm trying to launch a system in docker that has many init and upstart services and I get this error.

initctl: Unable to connect to Upstart:
Failed to connect to socket /com/ubuntu/upstart: Connection refused

All the workarounds suggest making a hard link to /bin/true to silence the error. But I need to have these services managed by upstart for restart-ability and for upstart emit events to work...

As it seems docker does not support this, I'm considering the gross hack of writing a script to launch all the services in /etc/rcX.d and keep track of the PIDs. That doesn't solve lack of emit events from upstart.

Any other ideas how to launch upstart processes in docker?

like image 626
Goblinhack Avatar asked Jan 20 '15 21:01

Goblinhack


People also ask

How does upstart start multiple services at once?

Upstart uses job definition files in /etc/init to define on what events a service should be started. So, while the system is booting, upstart processes various events, and then can start multiple services in parallel.

What is the purpose of upstart?

This was the main reason that Upstart was created. Upstart uses job definition files in /etc/init to define on what events a service should be started. So, while the system is booting, upstart processes various events, and then can start multiple services in parallel.

How to check if a service has been converted to upstart?

If we want to use the official Upstart way (Note that, for the moment, not all services have been converted to Upstart), we could use the following commands: status SERVICE - This will tell us if a converted service is running or not. Note that this is deprecated in favor of start, stop, status & restart.

What is the use of upstart job in Linux?

This allows them to fully utilize the resources of the system, for instance, by starting a disk-bound service up while another CPU-bound service runs, or while the network is waiting for a dynamic IP address to be assigned. You can see all of the upstart job files by running ls /etc/init/*.conf


2 Answers

Unfortunately, upstart does not work inside of a docker container because they do some magic with the init system.

This issue explains:

If your application uses upstart, this wont fit well in bare docker images, and even more if they divert /sbin/init or /sbin/initctl to something like /bin/true or /dev/null. You application may use service to start if this one has an old school systemV initscript and if the initctl command has not been diverted.

In the case of salt-minion, on ubuntu the packaging uses an upstart job and no classical init script so it is normal that it wont start in both cases.

And this one says:

Because Docker replaces the default /sbin/init with its own, there's no way to run the Upstart init inside a Docker container.

like image 167
Rémy Greinhofer Avatar answered Oct 05 '22 01:10

Rémy Greinhofer


You should definitely be able to do that. It's really not the way "Docker Way" but it's very possible. You might want to consider simply using the phusion/baseimage base image, it's got support for runit built in. If you'd rather use upstart just look at how they've implemented the entrypoint, /sbin/myinit, and follow that.

like image 33
Abdullah Jibaly Avatar answered Oct 05 '22 02:10

Abdullah Jibaly