我尝试通过以下 Dockerfile 将 Squid 放入 Docker 映像中:
FROM ubuntu:22.10
ENV TZ="Europe/Berlin"
ENV APT_HTTP_PROXY="Acquire::http::proxy \"http://192.168.0.2:8080/\";"
ENV APT_HTTPS_PROXY="Acquire::http::proxy \"http://192.168.0.2:8080/\";"
ENV APT_FTP_PROXY="Acquire::http::proxy \"http://192.168.0.2:8080/\";"
ENV DEBIAN_FRONTEND=noninteractive
# insert modified config
COPY squid.conf.tp /etc/squid/
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
echo $APT_HTTP_PROXY >> /etc/apt/apt.conf && \
echo $APT_HTTPS_PROXY >> /etc/apt/apt.conf && \
echo $APT_FTP >> /etc/apt/apt.conf && \
apt-get update --yes -q && \
apt-get install --yes -q squid && \
rm -rf /var/lib/apt/lists/* && \
/usr/sbin/squid -z
VOLUME ["/squid_data"]
EXPOSE 3128
CMD ["/usr/sbin/squid", "-f /ecc/squid/squid.conf.tp", "--foreground", "-s", "-Y", "-C"]
但 squid 无法启动,并出现错误:
FATAL: Unable to open configuration file: /ecc/squid/squid.conf.tp: (2) No such file or directory
当我将CMD修改为:
CMD ["/usr/bin/ls", "-alh", "/etc/squid" ]
我有
drwxr-xr-x 3 root root 6 Jul 22 11:33 .
drwxr-xr-x 43 root root 96 Jul 22 12:24 ..
drwxr-xr-x 2 root root 3 Jul 22 11:33 conf.d
-rw-r--r-- 1 root root 1.8K Jun 21 17:38 errorpage.css
-rw-r--r-- 1 root root 334K Jun 21 17:38 squid.conf
-rw-r--r-- 1 root root 334K Jul 21 14:00 squid.conf.tp
一切看起来都很好,我看不出有什么问题。如果没有 -f 选项,squid 会按预期启动(但配置错误)。
我第一次接触docker,显然,我搞错了什么,但是怎么办呢。