i have a ubuntu machine that hosts a docker container. 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.
my view is to ssh into docker host from the docker container. so when i run command ssh in the docker container its saying ssh not found. so,basically ssh is not installed in the container. how can i install ssh in the container. is there any way to accomplish this scenario?.
The SFTP server can be easily deployed to any platform that can host containers based on Docker. Below are deployment methods for: Docker CLI. Docker-Compose.
Well, as part of the image file you'll simply have to install openssh-server:
sudo apt-get install openssh-server
The problem then is that traditionally, a running docker container will only run a single command. You can get around this problem by using something like supervisord. There's an example in the docker docs: https://docs.docker.com/engine/admin/using_supervisord/
Your dockerfile might look like this:
FROM ubuntu:16.04
MAINTAINER [email protected]
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]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With