How to start a Service in an Alpine Container

4 posts / 0 new
Last post
#1 Thu, 2017-05-11 20:41
scottelundgren
  • scottelundgren's picture
  • Offline
  • Last seen: 3 months 3 weeks ago
  • Joined: 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

Mon, 2017-08-21 17:23
fadlykasim
  • fadlykasim's picture
  • Offline
  • Last seen: 3 months 3 weeks ago
  • Joined: 2017-08-21

rc-service is part of openrc, install openrc

apk add openrc --no-cache

Mon, 2017-08-21 19:47
scottelundgren
  • scottelundgren's picture
  • Offline
  • Last seen: 3 months 3 weeks ago
  • Joined: 2017-05-11

openrc is already installed. it's the 5th line of the Dockerfile.

Sun, 2017-08-27 11:23
pwFoo
  • pwFoo's picture
  • Offline
  • Last seen: 3 months 2 weeks ago
  • Joined: 2015-08-27

You need to start openrc / init as pid 1.
Maybe that link could help:
https://github.com/gliderlabs/docker-alpine/issues/42

Log in or register to post comments