Docker alpine image's basic commands are not working

SLOBY picture SLOBY · Sep 13, 2016 · Viewed 20k times · Source

docker started to produce weird bugs when I was using a few simple alpine based containers. Two of these problems are:

  • rc-update was not found when i was trying to use it
  • after installing openssh package, there was nothing in /etc/ssh or there was no /etc/init.d/sshd to start/restart the service

To avoid confusion I checked out a widely used container that serves as a simple SSH server. You can do it by executing:

git clone https://github.com/chamunks/alpine-openssh.git

After this go into the alpine-openssh directory and build the container with:

docker build -t alpine-openssh .

Mine produces the following:

Sending build context to Docker daemon 125.4 kB
Step 1 : FROM alpine
 ---> 4e38e38c8ce0
Step 2 : MAINTAINER Chamunks <[email protected]>
 ---> Running in c21d3fa28903
 ---> f32322a2871a
Removing intermediate container c21d3fa28903
Step 3 : COPY sshd_config /etc/ssh/sshd_config
 ---> 392364fc35ce
Removing intermediate container 4176ae093cb8
Step 4 : ADD https://gist.githubusercontent.com/chamunks/38c807435ffed53583f0/raw/ec868d1b45e248eb517a134b84474133c3e7dc66/gistfile1.txt /data/.ssh/authorized_keys
Downloading [==================================================>]    864 B/864 B
 ---> c3899b675728
Removing intermediate container f83629b6fa9b
Step 5 : RUN apk add --update openssh &&     rc-update add sshd &&     rc-status &&     touch /run/openrc/softlevel &&     /etc/init.d/sshd start &&     /etc/init.d/sshd stop &&     adduser -D user -h /data/
 ---> Running in 1d1aad9d1678
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/3) Installing openssh-client (7.2_p2-r3)
(2/3) Installing openssh-sftp-server (7.2_p2-r3)
(3/3) Installing openssh (7.2_p2-r3)
Executing busybox-1.24.2-r9.trigger
OK: 8 MiB in 14 packages
/bin/sh: rc-update: not found
The command '/bin/sh -c apk add --update openssh &&     rc-update add sshd &&     rc-status &&     touch /run/openrc/softlevel &&     /etc/init.d/sshd start &&     /etc/init.d/sshd stop &&     adduser -D user -h /data/' returned a non-zero code: 127

Notice the /bin/sh: rc-update: not found part. This should work but it doesn't. I restarted my docker service, checked out docker's forums but no similar issue has been reported so far.

Any ideas why does it happen?

Answer

Matt picture Matt · Sep 13, 2016

The rc-update tool is a part of the openrc package

apk add openrc