Ubuntu docker container with upstart and syslog
Asked Answered
F

1

8

After searching around, I'm still confused whether you can have a docker container running Ubuntu with a working init system (upstart) and syslog, or not.

I know docker containers are meant for running a single process and not a full OS, but my use case is testing a daemon on various linux distros, making sure the daemon starts, stops and restarts successfully on crashes, etc., with logging to syslog. So I'm trying to decide if I can use a docker container for this or maybe I would be better of with Vagrant.

Some resources I found are confusing:

  • Container cannot connect to Upstart docker/docker#1024

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

  • Using Supervisor with Docker

    Traditionally a Docker container runs a single process when it is launched, for example an Apache daemon or a SSH server daemon. Often though you want to run more than one process in a container. There are a number of ways you can achieve this ranging from using a simple Bash script as the value of your container’s CMD instruction to installing a process management tool.

So basically what I need at the end is to be able to run:

$ initctl start <daemon>
$ initctl stop <daemon>

of course after creating the necessary conf file at /etc/init/<daemon>.conf, and see the logs with syslog.

Fountainhead answered 21/10, 2015 at 8:30 Comment(3)
Have a look at baseimage-docker github.com/phusion/baseimage-docker which has an init system and a syslogUnwisdom
Yes but it's not upstart. My daemon detects upstart as the init system, since it's the default on Ubuntu, so it then uses initctl. Which won't work with their custom init system.Fountainhead
Have you considered an init system other than upstart? I know phusion[1] uses ubuntu as its baseimage. It uses runit[2]. There are also other daemons out there like supervisor[3]. [1]: github.com/phusion/baseimage-docker [2]: smarden.org/runit [3]: supervisord.orgHeiser
I
-1

see https://github.com/BITPlan/docker-stackoverflowanswers/tree/master/33233329 to repeat the steps

Going from the Dockerfile

FROM ubuntu:14.04

building it:

docker build -t bitplan/ubuntutest:0.1 .
Sending build context to Docker daemon 2.048 kB
Step 0 : FROM ubuntu:14.04
---> 0a17decee413
Successfully built 0a17decee413

running it:

docker run -it bitplan/ubuntutest:0.1 /bin/bash

and checking the running services:

 root@50a738241d03:/# service --status-all
 [ ? ]  console-setup
 [ + ]  cron
 [ ? ]  killprocs
 [ ? ]  kmod
 [ ? ]  networking
 [ ? ]  ondemand
 [ - ]  procps
 [ ? ]  rc.local
 [ + ]  resolvconf
 [ - ]  rsyslog
 [ ? ]  sendsigs
 [ - ]  sudo
 [ - ]  udev
 [ ? ]  umountfs
 [ ? ]  umountnfs.sh
 [ ? ]  umountroot
 [ - ]  urandom

You can see that there are multiple services running in a typical OS based container. If you install more stuff like apache, mysql and the like than there will be more services.

So if you'd like to start more of these I'd recommend to use

service start service stop

which you'll find e.g. in the entrypoint of our docker-mediawiki image at:

https://github.com/BITPlan/docker-mediawiki/blob/master/docker-entrypoint.sh

see e.g.

service mysql start

in there.

Irfan answered 21/10, 2015 at 10:30 Comment(4)
I'm not sure how this answers my question. I know you can install any services you'd like, but the question was specifically if you can have upstart working in an Ubuntu container. Basically to be able to replicate a standard Ubuntu machine.Fountainhead
See askubuntu.com/questions/353382/service-vs-initctl for the difference. I am not using initctl myself - since service is the older concept I am assuming that if the service approach works (which it does in my environment) then the initctl approach should also workIrfan
Not really. In a default ubuntu:14.04 container, /sbin/initctl has exit 0.Fountainhead
I mean that is everything it contains.Fountainhead

© 2022 - 2024 — McMap. All rights reserved.