Skip to content

Instantly share code, notes, and snippets.

@hughshen
Created September 15, 2020 15:15
Show Gist options
  • Save hughshen/660c83cc7e91536a0fbcb12f47af918b to your computer and use it in GitHub Desktop.
Save hughshen/660c83cc7e91536a0fbcb12f47af918b to your computer and use it in GitHub Desktop.
Dockerize an SSH service
FROM ubuntu:18.04
ARG USER=docker
ARG PASS=docker
ARG UID=1000
ARG GID=1000
RUN sed -i 's/\(archive\|security\).ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \
&& mkdir /var/run/sshd \
&& apt-get update \
&& apt-get install -y \
git \
vim \
curl \
wget \
sudo \
net-tools \
openssh-server \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
RUN groupadd -g ${GID} ${USER} \
&& useradd -rm -s /bin/bash -g ${GID} -G sudo -u ${UID} ${USER} \
&& echo "${USER}:${PASS}" | chpasswd
CMD ["/usr/sbin/sshd", "-D"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment