According to Alpine wiki I have to run rc-service apache2 start
after 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?
Asked
Active
Viewed 3.5k times
20

Psycho Punch
- 6,418
- 9
- 53
- 86
-
It's not a duplicate question, but still relevant. Thanks for noting that. – ibaralf Sep 29 '17 at 07:03
2 Answers
12
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

VonC
- 1,262,500
- 529
- 4,410
- 5,250
9
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)

lucsan
- 712
- 9
- 10
-
1Quite impresive. I don't know the rc doesn't installed by default. Thanks for mentioning. – Benyamin Limanto Feb 05 '19 at 01:07