Thursday, February 7, 2019

Example of docker with ssh X forwarding

Dockerfile

FROM ubuntu:18.10
RUN echo nameserver XX.XX.XX.XX > /etc/resolv.conf && echo "Acquire::ftp::proxy \"http://proxy.XX:8080\";" > /etc/apt/apt.conf &&  echo "Acquire::http::proxy \"http://proxy.XX:8080\";" >> /etc/apt/apt.conf &&  echo "Acquire::https::proxy \"http://proxy.XX:8080\";" >> /etc/apt/apt.conf  &&   apt-get update && apt-get install -y  x11-apps  openssh-server   language-pack-en-base  iputils-ping && mkdir -p  /var/run/sshd && groupadd -g 1000 fabio&& useradd -m -u 1000 -g fabio -s /bin/bash fabio
COPY ./sshd_config /etc/ssh/sshd_config

where 
x11-apps is for xeyes
iputils-ping is for ping
language-pack-en-base fixes the locale
mkdir -p  /var/run/sshd fixes an ssh bug source: https://github.com/ansible/ansible-container/issues/141

and where sshd_config has the options (be sure all are set)

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

to make a host-only network

docker network create -d bridge --internal hostonly




No comments:

Post a Comment