Skip to content

Latest commit

 

History

History
167 lines (113 loc) · 4.62 KB

README.md

File metadata and controls

167 lines (113 loc) · 4.62 KB

motionbank/squid:5.7-2

A more current fork of sameersbn/squid (Version 5.7)

Introduction

Dockerfile to create a Docker container image for Squid proxy server.

Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator.

Contributing

If you find this image useful here's how you can help:

  • Send a pull request with your awesome features and bug fixes

Getting started

Installation

Automated builds of the image are available on Dockerhub and is the recommended method of installation.

docker pull motionbank/squid:5.7-2

Alternatively you can build the image yourself.

docker build -t motionbank/squid github.com/motionbank/docker-squid

Quickstart

Start Squid using:

docker run --name squid -d --restart=always \
  --publish 3128:3128 \
  --volume /srv/docker/squid/cache:/var/spool/squid \
  motionbank/squid:5.7-2

Alternatively, you can use the sample docker-compose.yml file to start the container using Docker Compose

Command-line arguments

You can customize the launch command of the Squid server by specifying arguments to squid on the docker run command. For example the following command prints the help menu of squid command:

docker run --name squid -it --rm \
  --publish 3128:3128 \
  --volume /srv/docker/squid/cache:/var/spool/squid \
  motionbank/squid:5.7-2 -h

Persistence

For the cache to preserve its state across container shutdown and startup you should mount a volume at /var/spool/squid.

The Quickstart command already mounts a volume for persistence.

SELinux users should update the security context of the host mountpoint so that it plays nicely with Docker:

mkdir -p /srv/docker/squid
chcon -Rt svirt_sandbox_file_t /srv/docker/squid

Configuration

Squid is a full featured caching proxy server and a large number of configuration parameters. To configure Squid as per your requirements mount your custom configuration at /etc/squid/squid.conf.

docker run --name squid -d --restart=always \
  --publish 3128:3128 \
  --volume /path/to/squid.conf:/etc/squid/squid.conf \
  --volume /srv/docker/squid/cache:/var/spool/squid \
  motionbank/squid:5.7-2

To reload the Squid configuration on a running instance you can send the HUP signal to the container.

docker kill -s HUP squid

Usage

Configure your web browser network/connection settings to use the proxy server which is available at 172.17.0.1:3128

If you are using Linux then you can also add the following lines to your .bashrc file allowing command line applications to use the proxy server for outgoing connections.

export ftp_proxy=http://172.17.0.1:3128
export http_proxy=http://172.17.0.1:3128
export https_proxy=http://172.17.0.1:3128

To use Squid in your Docker containers add the following line to your Dockerfile.

ENV http_proxy=http://172.17.0.1:3128 \
    https_proxy=http://172.17.0.1:3128 \
    ftp_proxy=http://172.17.0.1:3128

Logs

Unlike the original version, this fork does not log to file, but only to stdout.

For reference, see this comment.

Maintenance

Upgrading

To upgrade to newer releases:

  1. Download the updated Docker image:
docker pull motionbank/squid:5.7-2
  1. Stop the currently running image:
docker stop squid
  1. Remove the stopped container
docker rm -v squid
  1. Start the updated image
docker run -name squid -d \
  [OPTIONS] \
  motionbank/squid:5.7-2

Shell Access

For debugging and maintenance purposes you may want access the containers shell. If you are using Docker version 1.3.0 or higher you can access a running containers shell by starting bash using docker exec:

docker exec -it squid bash