skip to Main Content

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


  1. You can also start the ssh daemon to run in the background
    here is an example:

    RUN service ssh start 
    CMD ["/usr/sbin/sshd", "-D"]
    

    this will start the ssh daemon in the container in a background mode

    Login or Signup to reply.
  2. I believe, best entrypoint for a SSH container would be:

    ENTRYPOINT ["/usr/sbin/sshd","-eD"]
    
    • -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 with docker logs <containerName>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search