5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dockerに Squidを

Last updated at Posted at 2017-04-25

楽して使うにはイメージを取ってくるのが一番。探してみる。

[root@Dockh ~]# docker search squid
INDEX       NAME                                       DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/sameersbn/squid                                                                  99                   [OK]
docker.io   docker.io/minimum2scp/squid                squid3 cache service container running on ...   14                   [OK]
docker.io   docker.io/malaohu/squid-with-net-speeder   auto build squid proxy                          12                   [OK]
docker.io   docker.io/orangeacme/squid                 Squid running as a caching proxy with a 10...   5                    [OK]
docker.io   docker.io/cloudposse/squid                 Squid with `basic-auth` support.                3                    [OK]
docker.io   docker.io/scbunn/squid                     Squid docker container based on alpine          3                    [OK]
docker.io   docker.io/vimagick/squid                   A caching proxy for the Web supporting HTT...   2                    [OK]
docker.io   docker.io/colstrom/squid                   A full-featured Web proxy cache server.         1                    [OK]
docker.io   docker.io/reddec/squid                     Docker (at least 1.3) image for Squid3 wit...   1                    [OK]
docker.io   docker.io/b4tman/squid                     Squid container based on Alpine Linux           0                    [OK]
docker.io   docker.io/babim/squid                      Squid on debian and alpine linux. With or ...   0                    [OK]
docker.io   docker.io/cbolt/squid                      basic squid container                           0                    [OK]
docker.io   docker.io/diouxx/squid                     Install and run an Squid3 instance. You ca...   0                    [OK]
docker.io   docker.io/ggtwlb0314/squid                 squid proxy                                     0                    [OK]
docker.io   docker.io/greymd/squid                     Squid proxy server                              0                    [OK]
docker.io   docker.io/jameseckersall/squid             Squid                                           0                    [OK]
docker.io   docker.io/konstruktoid/squid               Squid, a caching proxy, Docker image            0                    [OK]
docker.io   docker.io/noodle05/squid                   Alpine 3.4 based squid docker                   0                    [OK]
docker.io   docker.io/nouchka/squid                    Squid3 container                                0                    [OK]
docker.io   docker.io/oddlid/squid                     sameersbn/squid with tini                       0                    [OK]
docker.io   docker.io/reachlin/squid                   A very simple Squid proxy                       0                    [OK]
docker.io   docker.io/rkrahl/squid                     A docker image for the Squid proxy server       0                    [OK]
docker.io   docker.io/sftech/squid                     Squid proxy server                              0                    [OK]
docker.io   docker.io/whatwedo/squid                   squid proxy                                     0                    [OK]
docker.io   docker.io/zjqzero/squid                    squid                                           0                    [OK]
[root@Dockh ~]#

STARSが99のがあるのでこれにする。sameersbn/squid

[root@Dockh ~]# docker pull sameersbn/squid
Using default tag: latest
Trying to pull repository docker.io/sameersbn/squid ... 
latest: Pulling from docker.io/sameersbn/squid
c60055a51d74: Pull complete 
755da0cdb7d2: Pull complete 
969d017f67e6: Pull complete 
37c9a9113595: Pull complete 
a3d9f8479786: Pull complete 
e43d9de53575: Pull complete 
74d40cafa956: Pull complete 
46757dc2383a: Pull complete 
7cbbd948c587: Pull complete 
Digest: sha256:b2807a98fbae1ae16f529863a32fb0f06046f619fc879a711995e3a858a6bd50
[root@Dockh ~]#
[root@Dockh ~]# docker inspect sameersbn/squid
[
    {
        "Id": "sha256:1580e0cad2b05eebccf61fc253a6bfe7ccb9943e2681242df11e2c6f29dc7c47",
        "RepoTags": [
            "docker.io/sameersbn/squid:latest"
        ],
        "RepoDigests": [
            "docker.io/sameersbn/squid@sha256:b2807a98fbae1ae16f529863a32fb0f06046f619fc879a711995e3a858a6bd50"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2017-01-29T15:53:18.033768763Z",
        "Container": "0845d5ee83c66961fdfc351e9e14ba11260de082b8a9e94d8ee92b182d006e1f",
        "ContainerConfig": {
            "Hostname": "b6b4cb6241ef",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3128/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "SQUID_VERSION=3.3.8",
                "SQUID_CACHE_DIR=/var/spool/squid3",
                "SQUID_LOG_DIR=/var/log/squid3",
                "SQUID_USER=proxy"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "ENTRYPOINT [\"/sbin/entrypoint.sh\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:96e18ee674189cc01aeb8b75467a069bfd97fc3d9064584b20bc379fb7db9014",
            "Volumes": {
                "/var/spool/squid3": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "/sbin/entrypoint.sh"
            ],
            "OnBuild": [],
            "Labels": {}
        },
        "DockerVersion": "1.12.6-cs6",
        "Author": "sameer@damagehead.com",
        "Config": {
            "Hostname": "b6b4cb6241ef",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3128/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "SQUID_VERSION=3.3.8",
                "SQUID_CACHE_DIR=/var/spool/squid3",
                "SQUID_LOG_DIR=/var/log/squid3",
                "SQUID_USER=proxy"
            ],
            "Cmd": null,
            "ArgsEscaped": true,
            "Image": "sha256:96e18ee674189cc01aeb8b75467a069bfd97fc3d9064584b20bc379fb7db9014",
            "Volumes": {
                "/var/spool/squid3": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "/sbin/entrypoint.sh"
            ],
            "OnBuild": [],
            "Labels": {}
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 214690468,
        "VirtualSize": 214690468,
        "GraphDriver": {
            "Name": "devicemapper",
            "Data": {
                "DeviceId": "58",
                "DeviceName": "docker-8:17-134320192-24e20218a388eacba4ff196ee07f8fe37529bc65388f3bff09cd698d306535bd",
                "DeviceSize": "10737418240"
            }
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:918b1e79e35865cfaa7af9e07fa2a7aaaa2885e6bee964691a93c5db631b0aff",
                "sha256:83b575865dd109e77301a1be1e510cfffa6b89b9ff6355df22b5008315778263",
                "sha256:153bd22a8e96919e8eb890cc50aba51d7c16ea0746c2f020f21312f88e65f5c8",
                "sha256:ca893d4b83a60ef4e859785bc6b4072242ae07c7d6d0a07098847bc281b525b8",
                "sha256:c9fc7024b4847236789c072f13ee0c5f1e8718062df63654ce71ba05c4dd0ddc",
                "sha256:7ecd1524402ed555e4e881ef1d3f3b46c10ba2c851d82de90571e9112ef291d6",
                "sha256:b2a1524624a8b868b835c52f759c86c119424c7519c65f3bf872e6649e7ef77e",
                "sha256:5f5800720d1cc1d218541c1ce1c9c75acf7e2ee716787906494dee66f4e7d6e8",
                "sha256:39207ee2ecabb5309afb8bd58d21cf7e77cfa78f88e98b5e05e9f89bdce37334"
            ]
        }
    }
]
[root@Dockh ~]# 

そのまま起動すると、ログのタイムスタンプが読めないので/etc/squid3/squid.conf を以下のように修正

docker exec -it squid vi /etc/squid3/squid.conf

[root@Dockh squid]# grep -v '^\s*#' squid.conf |grep -v '^\s*$'
acl localnet src 10.0.0.0/8	# RFC1918 possible internal network
acl localnet src 172.16.0.0/12	# RFC1918 possible internal network
acl localnet src 192.168.0.0/16	# RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access deny to_localhost
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
cache_dir ufs /var/spool/squid3 100 16 256
logformat combined [%tl] %>a %[ui %[un "%rm %ru HTTP/%rv" %>Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
access_log /var/log/squid3/access.log combined
emulate_httpd_log on
coredump_dir /var/spool/squid3
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880
refresh_pattern .		0	20%	4320
[root@Dockh squid]# 
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?