Skip to content

Instantly share code, notes, and snippets.

@Neboer
Created April 6, 2026 01:37
Show Gist options
  • Select an option

  • Save Neboer/f03e3284dec2be2497dd196875f98345 to your computer and use it in GitHub Desktop.

Select an option

Save Neboer/f03e3284dec2be2497dd196875f98345 to your computer and use it in GitHub Desktop.
chinese-ubuntu-docker
FROM registry.neboer.site/library/ubuntu:22.04
ENV container=docker \
DEBIAN_FRONTEND=noninteractive \
TZ=Asia/Shanghai \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8
RUN set -eux; \
cat > /etc/apt/sources.list <<'EOF'
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
EOF
RUN set -eux; \
ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime; \
echo "${TZ}" > /etc/timezone; \
apt-get update; \
apt-get install -y --no-install-recommends \
systemd \
systemd-sysv \
openssh-server \
vim \
tzdata \
ca-certificates; \
rm -rf /var/lib/apt/lists/*
RUN set -eux; \
mkdir -p /var/run/sshd /run/systemd; \
mkdir -p /root/.ssh; \
chmod 700 /root/.ssh; \
sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config; \
sed -ri 's/^#?PasswordAuthentication\s+.*/PasswordAuthentication no/' /etc/ssh/sshd_config; \
grep -q '^PubkeyAuthentication yes$' /etc/ssh/sshd_config || echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config; \
ssh-keygen -A; \
systemctl enable ssh.service
EXPOSE 22
STOPSIGNAL SIGRTMIN+3
CMD ["/sbin/init"]
@Neboer
Copy link
Copy Markdown
Author

Neboer commented Apr 6, 2026

use these params:

--net=xxx
--cgroupns=host
--cap-add SYS_ADMIN
--tmpfs /run --tmpfs /run/lock
-v /sys/fs/cgroup:/sys/fs/cgroup:rw
-p 2222:22
-v /xxx/id_ed25519.pub:/root/.ssh/authorized_keys:ro

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