Start sshd automatically with docker container

2019-02-11 17:48发布

Given:

  • container based on ubuntu:13.10
  • installed ssh (via apt-get install ssh)

Problem: each when I start container I have to run sshd manually service ssh start

Tried: update-rc.d ssh defaults, but it does not helps.

Question: how to setup container to start sshd service automatically during container start?

标签: docker sshd
4条回答
Anthone
2楼-- · 2019-02-11 18:08

Just try:

ENTRYPOINT service ssh restart && bash

in your dockerfile, it works fun for me!

more details here: How to automatically start a service when running a docker container?

查看更多
放我归山
3楼-- · 2019-02-11 18:10

Well, I used the following command to solve that

docker run -i -t  mycentos6 /bin/bash -c '/etc/init.d/sshd start && /bin/bash'
查看更多
来,给爷笑一个
4楼-- · 2019-02-11 18:23

You can try a more elegant way to do that with phusion/baseimage-docker

https://github.com/phusion/baseimage-docker#readme

查看更多
Explosion°爆炸
5楼-- · 2019-02-11 18:29

You can start ssh server when starting your container probably. Something like this:

docker run ubuntu /usr/sbin/sshd -D

Check out this official tutorial.

查看更多
登录 后发表回答