Docker-alpine: can't use service or rc-service

Created on 5 Jun 2016  路  24Comments  路  Source: gliderlabs/docker-alpine

Most helpful comment

rc-service is part of openrc, install openrc

apk add openrc --no-cache

All 24 comments

I just found https://github.com/gliderlabs/docker-alpine/issues/26 and it seems to be the same question.. So, what should I do to run the docker daemon inside an alpine docker image?

I'm trying to run a service inside of the docker alpine:edge image but am getting the same result.

For context:

cat /etc/*-release
3.4.0
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.4.0
PRETTY_NAME="Alpine Linux v3.4"
HOME_URL="http://alpinelinux.org"
BUG_REPORT_URL="http://bugs.alpinelinux.org"
bash: rc-service: command not found

As described here, "Alpine Linux uses OpenRC for its init system." However, I can't seem to be able to find it.

yeah, docker images based on alpine don't have service or rc-service enabled.

How to enable?

rc-service is part of openrc, install openrc

apk add openrc --no-cache

Alpine is so great lol

What then is the process for getting docker running?

~ # apk add openrc --no-cache
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/2) Installing openrc (0.35.5-r4)
Executing openrc-0.35.5-r4.post-install
(2/2) Installing docker-openrc (18.06.1-r0)
Executing busybox-1.28.4-r0.trigger
OK: 187 MiB in 26 packages
~ # which service
/sbin/service
~ # service docker start
 * WARNING: docker is already starting
~ # service docker status
 * You are attempting to run an openrc service on a
 * system which openrc did not boot.
 * You may be inside a chroot or you may have used
 * another initialization system to boot this system.
 * In this situation, you will get unpredictable results!
 * If you really want to do this, issue the following command:
 * touch /run/openrc/softlevel
~ # touch /run/openrc/softlevel
touch: /run/openrc/softlevel: No such file or directory
~ # mkdir -p /run/openrc
~ # touch /run/openrc/softlevel
~ # service docker status
 * status: stopped
~ # service docker start
 * WARNING: docker is already starting
~ # service docker restart
 * WARNING: docker is already starting
~ # service docker stop
 * ERROR: docker stopped by something else
~ # service docker start
 * WARNING: docker is already starting

I'm also having this problem, any ideas?

bash-4.4# service docker start
 * WARNING: docker is already starting

Thanks!

openrc is normally started via /sbin/init. But running an init system in docker is normally not recommended.

I'm hitting these errors as well. Did you solve it @rm-rf-etc ?

I'm also having this problem, any ideas?

bash-4.4# service docker start
 * WARNING: docker is already starting

Thanks!

Do you know the answer now?

I'm tired about this stuff. Yes, it's "small" and "secure", yes it is because even me the root user of it cannot do anything I want in it.

I'm tired about this stuff. Yes, it's "small" and "secure", yes it is because even me the root user of it cannot do anything I want in it.

Time to turn around and go back. hehe

Any update on this issue?
I am getting the same problem.

Same issue. I'm on alpine 3.9. So I did

apk add --no-cache docker openrc
service docker start

ouput:

 * WARNING: docker is already starting

But it's not!

$ ps
PID   USER     TIME  COMMAND
    1 root      0:00 /dev/init -- /bin/sh
    6 root      0:00 /bin/sh
   62 root      0:00 /bin/bash
  309 root      0:00 ps

I'm not sure why you care so much about the service docker start... What is wrong with

+   $ docker run -it --init --rm --privileged --volume /var/lib/docker alpine
/ # apk add --no-cache docker
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/12) Installing ca-certificates (20190108-r0)
(2/12) Installing libseccomp (2.4.1-r0)
(3/12) Installing runc (1.0.0_rc8-r0)
(4/12) Installing containerd (1.2.9-r0)
(5/12) Installing libmnl (1.0.4-r0)
(6/12) Installing libnftnl-libs (1.1.3-r0)
(7/12) Installing iptables (1.8.3-r0)
(8/12) Installing tini-static (0.18.0-r0)
(9/12) Installing device-mapper-libs (2.02.184-r0)
(10/12) Installing docker-engine (18.09.8-r0)
(11/12) Installing docker-cli (18.09.8-r0)
(12/12) Installing docker (18.09.8-r0)
Executing docker-18.09.8-r0.pre-install
Executing busybox-1.30.1-r2.trigger
Executing ca-certificates-20190108-r0.trigger
OK: 278 MiB in 26 packages
/ # dockerd >/tmp/docker.stdout 2>/tmp/docker.stderr &
/ # docker run --init --rm -it alpine
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
9d48c3bd43c5: Pull complete
Digest: sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb
Status: Downloaded newer image for alpine:latest
/ # echo 'This is inside nested docker'
This is inside nested docker
/ # touch /xxx
/ # ls -l /xxx
-rw-r--r--    1 root     root             0 Sep 20 22:58 /xxx
/ # / # echo 'This is inside the original container'
This is inside the original container
/ # ls -l /xxx
ls: /xxx: No such file or directory
/ #

?

There's also https://github.com/dockage/alpine/blob/master/3.9/openrc/Dockerfile . You then could just

rc-update add apache2

in you dockerfile and not touch ENTRYPOINT/CMD. It will start the openrc in the container as normal boot would. But than again, in your example, I would just start apache directly...

I posted hastily. I didn't understand how Docker started the container. (I deleted my note.)

I had rc-update add apache2 in my Dockerfile, but still got that message about touching softlevel. So, I tried replacing busybox init with openrc-init, and it worked.

In the Dockerfile, added:

RUN apk add openrc
RUN ln -sf /sbin/openrc-init /sbin/init
ENTRYPOINT ["/sbin/init"]

However, it didn't handle docker restart. It hangs on shutdown.

Update: followed your advice, got rid of openrc, ran httpd directly. Now it works.

So has the issue not progressed so far?

This issue is closed, so I'm not sure any progress can be expected.

What progress would you like to see? There generally should not be a need to run openrc in docker container.

I'm running a couple of different processes in an alpine docker container and watch their output with rsyslog. I wanted to use openrc so that I could reload rsyslogd after log file rotation - however, I discovered that I could simply have rsyslog output directly to /proc/1/fd/0, instead of a log file.
So, no need for openrc, I can simply run whatever processes I need directly in the entrypoint script.

Just posting this here in case someone lands on this page while searching for a similar problem.

I've thought that I'm clever one ... nope xD

 $ rc-update add docker boot && service docker restart
  * service docker added to runlevel boot
  * WARNING: docker is already starting

Instead of using rc-service, you can/should just run supervisord and then let it spawn any additional process in foreground.
See this sample.
https://github.com/TrafeX/docker-php-nginx

I figured out this Workaround to be able to start Secondary Services
Workaround for Secondary Services

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ncopa picture ncopa  路  4Comments

javixeneize picture javixeneize  路  4Comments

dinogun picture dinogun  路  3Comments

nrvnrvn picture nrvnrvn  路  4Comments

frebib picture frebib  路  4Comments