docker-alpine icon indicating copy to clipboard operation
docker-alpine copied to clipboard

can't use service or rc-service

Open luisrudge opened this issue 10 years ago • 31 comments

image

luisrudge avatar Jun 05 '16 20:06 luisrudge

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?

luisrudge avatar Jun 05 '16 20:06 luisrudge

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"
rc-service
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.

westy92 avatar Jul 28 '16 17:07 westy92

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

luisrudge avatar Jul 28 '16 18:07 luisrudge

How to enable?

dondre avatar Oct 24 '16 02:10 dondre

rc-service is part of openrc, install openrc

apk add openrc --no-cache

riccardo-rav avatar Oct 28 '16 20:10 riccardo-rav

Alpine is so great lol

ORESoftware avatar Aug 31 '17 06:08 ORESoftware

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

rm-rf-etc avatar Sep 11 '18 01:09 rm-rf-etc

I'm also having this problem, any ideas?

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

Thanks!

simmessa avatar Nov 26 '18 13:11 simmessa

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

ncopa avatar Nov 26 '18 15:11 ncopa

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

m0ar avatar Jan 30 '19 12:01 m0ar

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?

unihon avatar Mar 17 '19 15:03 unihon

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.

miranquil avatar Jul 18 '19 07:07 miranquil

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

marzdgzmn avatar Jul 19 '19 06:07 marzdgzmn

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

wollf01 avatar Aug 08 '19 10:08 wollf01

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

comunitius avatar Sep 10 '19 00:09 comunitius

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
/ #

?

graywolf avatar Sep 20 '19 22:09 graywolf

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...

graywolf avatar Sep 29 '19 12:09 graywolf

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.

johnkawakami avatar Oct 01 '19 08:10 johnkawakami

So has the issue not progressed so far?

LeslieSun avatar Jan 09 '20 07:01 LeslieSun

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.

graywolf avatar Jan 10 '20 21:01 graywolf