6

I am trying to create an image which contains an openssh server and start it when invoking the run command. I have taken the following steps:

docker pull ubuntu
docker run -d -it ubuntu bash
apt-get update
apt-get install openssh-server -y
exit
docker ps -a 
docker commit <CONTAINER ID> myimg
// tried the following three, same results
docker run -d myimg "/usr/sbin/sshd"
docker run -d myimg /usr/sbin/sshd -D
docker run -d myimg service ssh start

This runs the image then exits immediately, I am trying to get the service to keep up. What Am I doing wrong?

1 Answer 1

8

Figured it out. You must create a directory after installing openssh-server.

The error: Missing privilege separation directory: /var/run/sshd

docker pull ubuntu
docker run -it ubuntu /bin/bash
apt-get update
apt-get install openssh-server -y
mkdir /var/run/sshd
service ssh stop
exit
docker ps -a 
docker commit <CONTAINER ID> myimg
docker run -d -p <PORT>:22 myimg /usr/sbin/sshd -D

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .