Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't use service or rc-service #183

Closed
luisrudge opened this issue Jun 5, 2016 · 31 comments
Closed

can't use service or rc-service #183

luisrudge opened this issue Jun 5, 2016 · 31 comments

Comments

@luisrudge
Copy link

image

@luisrudge
Copy link
Author

I just found #26 and it seems to be the same question.. So, what should I do to run the docker daemon inside an alpine docker image?

@westy92
Copy link

westy92 commented Jul 28, 2016

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.

@luisrudge
Copy link
Author

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

@dondre
Copy link

dondre commented Oct 24, 2016

How to enable?

@riccardo-ravaro
Copy link

rc-service is part of openrc, install openrc

apk add openrc --no-cache

@ORESoftware
Copy link

Alpine is so great lol

@rm-rf-etc
Copy link

rm-rf-etc commented Sep 11, 2018

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

@simmessa
Copy link

I'm also having this problem, any ideas?

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

Thanks!

@ncopa
Copy link
Collaborator

ncopa commented Nov 26, 2018

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

@m0ar
Copy link

m0ar commented Jan 30, 2019

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

LynxAbraxas added a commit to LynxAbraxas/ctp2DF that referenced this issue Feb 25, 2019
@unihon
Copy link

unihon commented Mar 17, 2019

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?

@miranquil
Copy link

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.

@marzdgzmn
Copy link

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

@wollf01
Copy link

wollf01 commented Aug 8, 2019

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

@comunitius
Copy link

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

@graywolf
Copy link

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
Copy link

graywolf commented Sep 29, 2019

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

@johnkawakami
Copy link

johnkawakami commented Oct 1, 2019

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.

@LeslieSun
Copy link

So has the issue not progressed so far?

@graywolf
Copy link

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.

@fluxx-sleblanc
Copy link

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.

@webchi
Copy link

webchi commented Feb 12, 2020

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

@MorenoGentili
Copy link

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

@domibay-hugo
Copy link

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

@tarek-chen
Copy link

stopped

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

you can find its status still is stopped if you perform 'service docker status' after 'Service docker start'
always, so fxxking sad

@JsThiago
Copy link

JsThiago commented May 6, 2023

i dont know if anyone still has this problem but running sudo openrc worked for me

@alexdowad
Copy link

you can find its status still is stopped if you perform 'service docker status' after 'Service docker start' always, so fxxking sad

Just ran into the same issue, peeked at the source code for OpenRC to see what it is doing, ran with strace to confirm.

It turned out that you also need to mkdir /run/openrc/exclusive.

@lingchuL
Copy link

you can find its status still is stopped if you perform 'service docker status' after 'Service docker start' always, so fxxking sad

Just ran into the same issue, peeked at the source code for OpenRC to see what it is doing, ran with strace to confirm.

It turned out that you also need to mkdir /run/openrc/exclusive.

Thanks a lot! Worked for me!

@DadiAnas
Copy link

DadiAnas commented Jan 4, 2024

Sum up, for docker daemon as an example:

apk add openrc  --no-cache
mkdir -p /run/openrc/exclusive
touch /run/openrc/softlevel

apk add docker
service docker start
rc-update add docker

@Fungus-00
Copy link

Sum up, for docker daemon as an example:

apk add openrc  --no-cache
mkdir -p /run/openrc/exclusive
touch /run/openrc/softlevel

apk add docker
service docker start
rc-update add docker

It works indeed! Not only for docker, but sshd and any others.

@iltafah
Copy link

iltafah commented Apr 27, 2024

you can find its status still is stopped if you perform 'service docker status' after 'Service docker start' always, so fxxking sad

Just ran into the same issue, peeked at the source code for OpenRC to see what it is doing, ran with strace to confirm.

It turned out that you also need to mkdir /run/openrc/exclusive.

Thanks I faced the same problem when running vsftpd with rc-service, it works now.
Oh almighty God! guide Alpine creators to write good Docs, Amen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests