Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker alpine image's basic commands are not working

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?

like image 284
SLOBY Avatar asked Sep 12 '16 23:09

SLOBY


People also ask

Which Docker command run an alpine container in interactive mode?

--rm Automatically remove the container when it exits ( docker run --help ) -i Interactive mode (Keep STDIN open even if not attached) -t Allocate a pseudo-TTY.

What will the following Docker command do Docker pull Alpine?

Alpine is a lightweight Linux distribution so it is quick to pull down and run, making it a popular starting point for many other images. The pull command fetches the alpine image from the Docker registry and saves it in our system. In this case the registry is Docker Hub.


1 Answers

The rc-update tool is a part of the openrc package which is not included in the base image.

apk add openrc 
like image 115
Matt Avatar answered Sep 18 '22 15:09

Matt