I have the following Dockerfile:
# CONSTRAINT: I need to use this Base Image
FROM openjdk:8-jdk-alpine
RUN apk add openrc
# Reference:
# https://wiki.alpinelinux.org/wiki/Setting_up_a_ssh-server
RUN apk add openssh
RUN rc-update add sshd
# This fails, why?, how to fix it?
# RUN /etc/init.d/sshd start
# ...
# what to put here in order to install a SSH server?
# ...
# Just to keep the Container running
ENTRYPOINT ["tail", "-f", "/dev/null"]
To run that container I do:
$ docker build -t myorg/myapp .
$ docker run -d --name myapp-instance myorg/myapp
$ docker exec -ti myapp-instance /bin/sh
My question is: how to install a SSH server on that container?
I tried what is explained on this link:
https://wiki.alpinelinux.org/wiki/Setting_up_a_ssh-server
but when I do:
# rc-status
I get:
* Caching service dependencies ...
Service `hwdrivers' needs non existent service `dev' [ ok ]
Runlevel: sysinit
sshd [ stopped ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
Dynamic Runlevel: manual
and when I do:
# /etc/init.d/sshd start
I get:
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/blkio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/cpu/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/cpuacct/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/cpuset/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/devices/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/freezer/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/hugetlb/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/memory/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/net_cls/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/net_prio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/perf_event/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/pids/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 101: can't create /sys/fs/cgroup/systemd/tasks: Read-only file system
* 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
* ERROR: sshd failed to start
Any idea on how to make the SSH server to work on this doker container with the constraints highlighted on the Dockerfile?
If possible, please, provide the updated Dockerfile.
Thanks!