[英]installing ssh in the docker containers
i have a ubuntu machine that hosts a docker container. 我有一台托管Docker容器的Ubuntu计算机。 and in the docker container i am running a web service which must validate the user's password with the docker host's /etc/password.
在docker容器中,我正在运行一个Web服务,该服务必须使用Docker主机的/ etc / password验证用户的密码。
my view is to ssh into docker host from the docker container. 我的观点是从docker容器ssh进入docker主机。 so when i run command ssh in the docker container its saying ssh not found.
因此,当我在docker容器中运行命令ssh时,找不到它的说法ssh。 so,basically ssh is not installed in the container.
因此,基本上ssh没有安装在容器中。 how can i install ssh in the container.
我如何在容器中安装ssh。 is there any way to accomplish this scenario?.
有什么办法可以完成这种情况?
Well, as part of the image file you'll simply have to install openssh-server: 好吧,作为映像文件的一部分,您只需要安装openssh-server:
sudo apt-get install openssh-server
The problem then is that traditionally, a running docker container will only run a single command. 然后的问题是,传统上,正在运行的docker容器将仅运行单个命令。 You can get around this problem by using something like supervisord.
您可以通过使用supervisor之类的方法来解决此问题。 There's an example in the docker docs: https://docs.docker.com/engine/admin/using_supervisord/
docker docs中有一个示例: https : //docs.docker.com/engine/admin/using_supervisord/
Your dockerfile might look like this: 您的dockerfile可能看起来像这样:
FROM ubuntu:16.04
MAINTAINER examples@docker.com
RUN apt-get update && apt-get install -y openssh-server apache2 supervisor
RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/run/sshd /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 22 80
CMD ["/usr/bin/supervisord"]
Your supervisord.conf might look something like this: 您的supervisord.conf可能看起来像这样:
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.