具有upstart和syslog的Ubuntu docker容器 [英] Ubuntu docker container with upstart and syslog

查看:259
本文介绍了具有upstart和syslog的Ubuntu docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在搜索后,我仍然感到困惑,无论您是否可以使用工作的 init系统(upstart) syslog 运行Ubuntu的 docker容器 strong>,或不。

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.

我知道docker容器是用于运行单个进程而不是完整的操作系统,但我的用例是在各种linux发行版上测试一个守护进程,通过登录到syslog,确保守护程序启动,停止并成功重新启动等。所以我试图决定是否可以使用码头集装箱,或者我会更好的使用 Vagrant

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:


由于Docker用自己替换了默认的/ sbin / init,所以
没有办法在Docker容器内运行Upstart init。

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


  • 使用Supervisor与Docker


    传统上,Docker容器在启动时运行单个进程,例如Apache守护程序或SSH服务器守护程序。通常,您希望在容器中运行多个进程。有许多方法可以实现这一点,从使用简单的Bash脚本作为容器的 CMD 指令的值来安装流程管理工具。

    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>
    



    < ; daemon> .conf ,并查看带有 syslog 的日志。

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

    推荐答案

    请参阅
    https:// github。 com / BITPlan / docker-stackoverflowanswers / tree / master / 33233329
    重复步骤

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

    从Dockerfile

    Going from the Dockerfile

    FROM ubuntu:14.04
    

    建立它:

    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
    

    运行它:

    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
    

    您可以看到有多个服务在典型的基于操作系统的容器。如果你安装更多的东西,比如apache,mysql等等都会有更多的服务。

    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

    你会发现,例如在我们的docker-mediawiki图像的入口点:

    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

    参见例如

    service mysql start
    

    在那里。

    这篇关于具有upstart和syslog的Ubuntu docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆