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

查看:34
本文介绍了运行 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 中,我重新启动了正在运行的服务,但在 alpine 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天全站免登陆