How to start a Service in an Alpine Container
#1
Thu, 2017-05-11 20:41
scottelundgren
-
- Offline
- 1 month 2 weeks ago
- 2017-05-11
I'm trying to create a container that runs bind as a forward only DNS resolver that will start with the container. Below is my Dockerfile where I install the bind & openrc a-packs. What should I be doing to start the named service ?
FROM gliderlabs/alpine:latest RUN apk --update --no-cache add\ bind\ openrc COPY named.conf /etc/bind EXPOSE 53/udp 53/tcp CMD "rc-update add named boot"
which builds successfully but immediately exits when running the container with
docker run --name dns -d --publish 53:53/tcp --publish 53:53/udp <container id>
. I'm not sure how I should be interpreting the log message. It seems to be me the /bin/sh is telling me the rc-service binary is not in $PATH. However changing the CMD parameter to /sbin/rc-update add named boot
didn't work either:
$ docker logs dns /bin/sh: rc-service named start: not found
rc-service is part of openrc, install openrc
apk add openrc --no-cache
openrc is already installed. it's the 5th line of the Dockerfile.
You need to start openrc / init as pid 1.
Maybe that link could help:
https://github.com/gliderlabs/docker-alpine/issues/42