How do I run Apache 2 on Alpine in Docker?

浪子不回头ぞ 提交于 2019-12-21 03:33:26

问题


According to Alpine wiki I have to run rc-service apache2 startafter installation of Apache 2. However, there's no rc-service in the Alpine running inside the container. How do I get the service command to run inside Docker container?


回答1:


gliderlabs/docker-alpine issue 183 illustrate the docker Alpine image has no service or rc-service.

You can see instead nimmis/docker-alpine-apache based on nimmis/docker-alpine-micro, which includes a runit, used to handle starting and shutting down processes automatically started.

That initd will start the apache2 script, which calls:

exec /usr/sbin/httpd -D FOREGROUND -f /web/config/httpd.conf



回答2:


Alpine does not have rc-service installed by default. You need to install it (either as part of your Dockerfile build process or manually in the container).

The secret invocation is:

apk add openrc --no-cache

If you want to run it from outside the container (say docker run), then use:

docker run [options etc] bin/ash -c "apk add openrc --no-cache"

PS: rc-service is good for other things and stuff like mariadb (also not included in alpine)



来源:https://stackoverflow.com/questions/38035726/how-do-i-run-apache-2-on-alpine-in-docker

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