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

我只是一个虾纸丫 提交于 2019-11-30 03:03:06

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/28055715/running-services-upstart-init-d-in-a-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!