Skip to content

Instantly share code, notes, and snippets.

@WuSiYu
Created August 16, 2021 16:03
Show Gist options
  • Save WuSiYu/bbee5788242bcb99b9acbe5257aae522 to your computer and use it in GitHub Desktop.
Save WuSiYu/bbee5788242bcb99b9acbe5257aae522 to your computer and use it in GitHub Desktop.
A "full" ubuntu-server development environment docker image
FROM ubuntu:latest
LABEL maintainer="SiYu Wu <wu.siyu@hotmail.com>"
ENV DEV_USER=user
ENV UID=1000
ENV GID=1000
ENV DEF_PASSWD=password
ENV TZ=Asia/Shanghai
ENV LANG=en_US.UTF-8
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
yes | unminimize && \
apt install -y systemd sudo openssh-server bash-completion zsh git curl vim && \
addgroup --gid $GID $DEV_USER && \
adduser --uid $UID --gid $GID --gecos "" --disabled-password $DEV_USER && \
usermod -aG sudo $DEV_USER && \
echo "$DEV_USER:$DEF_PASSWD" | chpasswd && \
systemctl mask systemd-resolved.service && \
echo "LANG=$LANG" > /etc/default/locale && \
cp /usr/share/doc/util-linux/examples/securetty /etc/securetty
CMD ["systemd"]
@WuSiYu
Copy link
Author

WuSiYu commented Aug 16, 2021

Example usage

Build

sudo docker build -t devbox:v0.1 .

Run (w/o privileged)

sudo docker run -d -it --cap-add AUDIT_WRITE --name devbox --publish 8022:22 --hostname devbox -v ./data:/data:z devbox

Run (with privileged)

sudo podman run -it --name devbox --publish 8022:22 --hostname devbox -v ./data:/data --privileged devbox

@WuSiYu
Copy link
Author

WuSiYu commented Aug 16, 2021

Due to the apt cache file is "disabled" in ubuntu's docker image, apt's package name autocompletion will not work.

If you want to make it work, delete the following file in your container:

/etc/apt/apt.conf.d/docker-clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment