Skip to content

Squid caching proxy container image.

License

Notifications You must be signed in to change notification settings

mpreu/container-squid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Squid Container Image

Container image for the Squid caching proxy based on Alpine Linux.

Documentation

Getting the Image

The container image is published on Dockerhub and can be accessed with e.g.:

podman pull docker.io/mpreu/squid:5.9

Alternatively, the image is also available in the Github Container Registry:

podman pull ghcr.io/mpreu/squid:5.9

Configuration

To provide a squid.conf configuration file the mount point /etc/squid/squid.conf can be used:

podman run \
  --name squid \
  --volume /path/to/squid.conf:/etc/squid/squid.conf \
  docker.io/mpreu/squid:5.9

Command-line Parameters

For further customization additional command-line parameters are forwarded to Squid. For example, getting the current installed Squid version in the container can be displayed with:

podman run docker.io/mpreu/squid:5.9 --version

Persistent Cache and Logs

To allow persistent caches and logs during container shutdowns/restarts/... the following directories can be mapped to the host:

  • /var/spool/squid for caches
  • /var/log/squid for logs
podman run \
  --name squid \
  --volume /tmp/squid/cache:/var/spool/squid \
  --volume /tmp/squid/log:/var/log/squid \
  docker.io/mpreu/squid:5.9

In case persistent logs are not required, they can just be accessed with e.g.:

podman exec -it squid tail -f /var/log/squid/access.log

Running as a Service

When running Squid in a container, one usual use-case is to have it running as a service. This can be achieved on a systemd system using the following example unit deployed to e.g. '/etc/systemd/system/squid.service':

[Unit]
Description=Squid container service
After=network-online.target

[Service]
Restart=always
ExecStartPre=-/usr/bin/podman stop %n
ExecStartPre=-/usr/bin/podman rm %n
ExecStart=/usr/bin/podman run --rm \
                              --name %n \
                              --security-opt label=disable \
                              -p 3128:3128 \
                              -v /path/to/squid.conf:/etc/squid/squid.conf \
                              docker.io/mpreu/squid:5.9

[Install]
WantedBy=default.target

The Squid container service can then be started and enabled with:

systemctl enable --now squid