How to run Apache 2 on Alpine in Docker?

According to the Alpine wiki, I need to run rc-service apache2 start after installing Apache 2. However, there is no rc-service in Alpine mode inside the container. How to get a service command to launch a docker container?

+6
source share
2 answers

gliderlabs/docker-alpine issue 183 illustrates that the climbing gliderlabs/docker-alpine image does not have service or rc-service .

Instead, you can see nimmis/docker-alpine-apache based on nimmis/docker-alpine-micro , which includes runit, which is used to process startup and shutdown processes, starts automatically.

This initd will run an apache2 script that calls:

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

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

Secret call:

 apk add openrc --no-cache 

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

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

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

+1
source

All Articles