Created
October 25, 2021 18:47
-
-
Save npodonnell/be8d1b4314d0d6aa05c8d7f28969f432 to your computer and use it in GitHub Desktop.
Ubuntu 21.10 in docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Creates a persistent, SSHable ubuntu 21.10 in a container, including tmux. | |
docker stop my-ubuntu-ctr | |
docker rm my-ubuntu-ctr | |
docker rmi my-ubuntu | |
docker build -t my-ubuntu - << HERE | |
FROM ubuntu:21.10 | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt update -y \ | |
&& apt --no-install-recommends -y install \ | |
sudo \ | |
ca-certificates \ | |
openssh-server \ | |
iputils-ping \ | |
iproute2 \ | |
netcat \ | |
curl \ | |
traceroute \ | |
sudo \ | |
vim \ | |
tmux | |
RUN yes ubuntu | passwd | |
RUN useradd -m ubuntu && yes ubuntu | passwd ubuntu | |
RUN usermod -a -G sudo ubuntu | |
RUN chsh -s /bin/bash ubuntu | |
RUN echo '[[ ! -z \$TMUX ]] || tmux attach || tmux' >> /home/ubuntu/.bashrc | |
RUN ( \ | |
echo 'LogLevel DEBUG2'; \ | |
echo 'PermitRootLogin yes'; \ | |
echo 'PasswordAuthentication yes'; \ | |
) > /etc/ssh/sshd_config \ | |
&& mkdir /run/sshd | |
CMD ["/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_config"] | |
HERE | |
docker create \ | |
-it \ | |
--name "my-ubuntu-ctr" \ | |
--restart unless-stopped \ | |
-p 127.0.0.1:2222:22 \ | |
-m "2048m" \ | |
--cpus="2" \ | |
--cpuset-cpus="4,5" \ | |
my-ubuntu | |
docker start "my-ubuntu-ctr" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment