1 min readMay 14, 2020
Run sshd on docker via caprover
While it is quite easy to run docker via CapRover, it is not obvious how to set up sshd for a docker container.
Here is my Dockerfile for CapRover to get sshd ready
FROM ruby:latest# install dependencies
RUN apt-get update -qq && apt-get install -y openssh-serverRUN mkdir /var/run/sshd
RUN echo 'root:you_password' | chpasswd
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_configEXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
I use a full ruby image for developing purpose. If you use alpine image, you might need to use apk. And the defaults in /etc/ssh/sshd_config may be different.
Create an app in your CapRover instance, disable HTTP, and map server port, say 8888, to sshd port, 22.
Deploy the docker as usual. Now, you can connect to that instance by
ssh root@caprover_ip -p 8888
You can also turn on data persistency for keep data in hosting server.