0

I try to put a squid in a docker image via following Dockerfile:

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"]

but squid does not start with error:

 FATAL: Unable to open configuration file:  /ecc/squid/squid.conf.tp: (2) No such file or directory

When I modify the CMD into:

CMD ["/usr/bin/ls", "-alh", "/etc/squid" ]

I got

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

everything looks good to me, I can't see the problem. Without the -f option, squid starts as expected (but with the wrong config).

It's my first contact with docker, obviously, I got something wrong, but what.

Thomas P
  • 51
  • 1
  • 9
  • Is there any reason not to copy `squid.conf` and start `squid` w/o explicit config file? – Romeo Ninov Jul 22 '22 at 13:15
  • Yes, when I copy the modified `squid.conf` into `/ect/squid/` I got a interactive question on `apt-get update` 'your squid.conf has been modified, which version do you want to use ....'. – Thomas P Jul 24 '22 at 09:13
  • 1
    Two things, first: By moving the COPY command below the RUN command, I can use squid.conf without interactive question about modified config (super beginner mistake). Second: One can get rid of the interactive question by using options mentioned here. Then primary question "Why does the -f option not work?" is still open and relevant to me, because I want the config to be in a volume that I can update it at runtime and let squid reload it via `docker exec ...`. – Thomas P Jul 25 '22 at 08:31

0 Answers0