Sign inSign up

corray/ubuntu

By corray

•Updated 4 months ago

Image
0

30

corray/ubuntu repository overview

# 使用 Ubuntu 22.04 官方镜像
FROM hub-mirror.local.com:5000/library/ubuntu:24.04


# 替换为国内源(任选一个)
# 阿里云源


RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#http://mirrors.tuna.tsinghua.edu.cn/ubuntu#g' /etc/apt/sources.list.d/ubuntu.sources && \
    apt-get update && apt-get install -y \
      curl wget git vim nano \
      net-tools iputils-ping \
      htop tmux zip unzip \
      build-essential python3 \
      openssh-server sudo \
      nodejs npm \
      && rm -rf /var/lib/apt/lists/*



ARG SSH_PASSWORD=defaultpassword  # 默认值(可被构建时覆盖)
# 配置 SSH(可选)
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
    sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
    sed -i "s/#Port 22/Port 22222/" /etc/ssh/sshd_config && \
    mkdir -p /run/sshd && \
    echo "root:${SSH_PASSWORD}" | chpasswd

# 创建用户并添加公钥
RUN useradd -m -s /bin/bash corray && \
    mkdir -p /home/corray/.ssh && \
    echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHe6BjxRMWwewbEJ63p3dEs8eUiSKgfHdVnL0etGLjD " >> /home/corray/.ssh/authorized_keys && \
    chown -R corray:corray /home/corray/.ssh && \
    chmod 700 /home/corray/.ssh && \
    chmod 600 /home/corray/.ssh/authorized_keys


# 保持容器运行
CMD ["/usr/sbin/sshd", "-D"]


Tag summary

Content type

Image

Digest

sha256:61397fc31…

Size

329.4 MB

Last updated

4 months ago

docker pull corray/ubuntu:24.04-tools