1. 使用Dockerfile构建基于Alpine系统的dnsmasq镜像,并采用supervise守护进程,编辑Dockerfile文件,如下:
FROM aqzt/docker-alpine
LABEL maintainer=”aqzt.com (ppabc@qq.com)”
# webproc release settings
ENV HTTP_USER user
ENV HTTP_PASS Root123
ENV WEBPROC_VERSION 0.1.9
ENV WEBPROC_URL https://github.com/jpillora/webproc/releases/download/$WEBPROC_VERSION/webproc_linux_amd64.gz
# fetch dnsmasq and webproc binary
RUN apk update \
&& apk –no-cache add dnsmasq \
&& apk add –no-cache –virtual .build-deps curl \
&& curl -sL $WEBPROC_URL | gzip -d – > /usr/local/bin/webproc \
&& chmod +x /usr/local/bin/webproc \
&& apk del .build-deps
#configure dnsmasq
run mkdir -p /etc/default/
RUN echo -e “ENABLED=1\nIGNORE_RESOLVCONF=yes” > /etc/default/dnsmasq
EXPOSE 53/tcp 53/udp
ADD root /
2. 构建命令:docker build –tag dnsmasq:1.1 -f Dockerfile .
3. 启动docker镜像命令:
docker run –name dnsmasq -d -p 53:53/udp -p 8080:8080 -v /opt/dnsmasq.conf:/etc/dnsmasq.conf –log-opt “max-size=100m” -e “HTTP_USER=user” -e “HTTP_PASS=Root123” –restart always dnsmasq:1.1
或者
docker run -d –name dnsmasq -ti -p 53:53/udp -p 8080:8080 -v /opt/dnsmasq.conf:/etc/dnsmasq.conf –log-opt “max-size=100m” -e “HTTP_USER=user” -e “HTTP_PASS=Root123” dnsmasq:1.1
4. 启动后可以访问8080端口,登录的账号user密码是 Root123,登录后如图:
效果图
5. 可以直接在界面上修改配置,然后点【Restart】生效。
参考:
https://github.com/aqzt/docker-alpine/blob/master/dnsmasq/Dockerfile