1.编写 Dockerfile
使用 Ubuntu 22.04 作为基础镜像
FROM ubuntu:22.04
# 设置环境变量,避免交互提示
ENV DEBIAN_FRONTEND=noninteractive
# 备份原始的软件源配置文件,并替换为阿里云镜像源
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list \
&& sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
# 安装 wget 和 gnupg
RUN apt-get update && apt-get install -y \
wget \
gnupg \
&& rm -rf /var/lib/apt/lists/*
# 添加 Webmin 软件源
RUN echo "deb http://download.webmin.com/download/repository sarge contrib" >> /etc/apt/sources.list \
&& wget -qO - http://www.webmin.com/jcameron-key.asc | apt-key add -
# 更新系统软件包列表并安装 Samba 和 Webmin
RUN apt-get update && apt-get install -y \
webmin
RUN apt-get install -y net-tools iproute2 nano
RUN rm -rf /var/lib/apt/lists/*
# 配置 Webmin 允许远程访问
RUN sed -i 's/ssl=1/ssl=0/' /etc/webmin/miniserv.conf \
&& sed -i 's/allow=127.0.0.1/allow=0.0.0.0/' /etc/webmin/miniserv.conf
# 暴露 mail 和 Webmin 的端口
EXPOSE 25 465 587 993 995 10000
# 启动 Webmin 服务
CMD service webmin start && tail -f /dev/null
2.构建镜像
docker build -t webmin:v1.0 .
3.运行容器
docker run --restart=always -d -p 25:25 -p 465:465 -p 587:587 -p 993:993 -p 995:995 -p 10000:10000 --name webmin webmin:v1.0
4.修改登录密码
docker exec -it webmin bash
passwd