Docker, redirecting to virtualbox port

181 views Asked by At

I have a local machine (ip : 192.168.1.3) on which I have installed boot2docker (with a SSH container created with https://docs.docker.com/examples/running_ssh_service/) on ip 192.168.53.23.

I need to use portforwarding :

  • to be able to connect my docker ssh container
  • from a different machine on my local network (ip : 192.168.1.x) from a specific port. Like 192.168.1.2:7000 to 192.168.53.23:7000 for example

Here's my Dockerfile :

FROM ubuntu:14.04
MAINTAINER Marvin Frachet <[email protected]>


# SSH
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:xxxxxx' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]



# NodeJS Apache2
RUN apt-get update &&\
        apt-get -y upgrade &&\
        apt-get -y install nodejs nodejs-legacy nodejs-dev npm git curl apache2

And here's how I run my container :

docker run -d -P --name test_sshd eg_sshd

Then I use this line to get the current port used by the ssh server :

sudo docker port test_sshd 22

What should I do to port forward, and allow my ssh container being accessible from wherever on the local network ?

EDIT :

What I need is to specify a port when running the ssh server. So I can port forward on this port

0

There are 0 answers