When my Ubuntu Docker container is started, I want SSH server to be running and the container should not quit immediately until I run docker stop $container_id
Is there any difference between these 3 ENTRYPOINT
? Is there a better way to do it?
ENTRYPOINT service ssh restart && bash
ENTRYPOINT service ssh restart && tail -f /dev/null
ENTRYPOINT service ssh restart && sleep infinity
2
Answers
You can also start the
ssh daemon
to run in the backgroundhere is an example:
this will start the ssh daemon in the container in a background mode
I believe, best entrypoint for a SSH container would be:
-D
: to make it daemon mode(running in the background but using tty)-e
: log to stderr instead of log file. this way You can check ssh logs withdocker logs <containerName>