运行2个程序的Docker Alpine Linux [英] Docker Alpine linux running 2 programs

查看:134
本文介绍了运行2个程序的Docker Alpine Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用alpine linux创建docker映像,运行后将创建带有2个正在运行的程序的容器。这2个(我认为-我不太了解docker)无法分开,因为第一个程序更改了秒配置文件,然后也应该重新启动该程序。

I am trying to create docker image with alpine linux, which after run will create container with 2 running programs. This 2 (in my opinion - I don't know docker well) can't be separated because first program changes the seconds configuration file and then should restart that program too.

我正在努力运行两个程序。我添加了自己的脚本,该脚本应该运行该程序,但我缺少一些东西-脚本是每行2行是用于运行该程序的命令-而且它仅启动第一个程序。

I am struggling how to run both programs. I have added own script which should run that programs but I am missing something - script is 2 lines on each line is command for running that program - and it only starts first program.

在带有python子进程和systemctl命令的ubuntu中,我重新启动运行的服务,但在高山linux中,它作为程序运行,我不知道如何重新启动/重新加载它。

In ubuntu with python subprocess and systemctl command I restart running service but in alpine linux it's running as program and I don't know how to restart/reload it.

感谢每位帮助

推荐答案

我建议您看一下 supervisord 方法。您可以在 docker文档中找到使用方法。

I would suggest to look at supervisord approach. You can find how to use it in docker documentation.

例如:

1。 Dockerfile 是:

FROM alpine:latest
RUN apk update && apk add --no-cache supervisor openssh nginx
COPY supervisord.conf /etc/supervisord.conf
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]

2。 supervisord.conf 是:

[supervisord]
nodaemon=true

[program:sshd]
command=/usr/sbin/sshd -D

[program:nginx]
command=nginx -c /etc/nginx/nginx.conf

这篇关于运行2个程序的Docker Alpine Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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