Debian
RaspberryPi
docker
apt-cacher-ng

[メモ] らずぱいで、apt-cacher-ngのサーバをDockerにて

概要

環境

  • Raspberry Pi 3 model B
  • Docker

    pi@rpi-07e7aa:~/apt-cacher-ng $ docker --version
    Docker version 17.10.0-ce, build f4ffd25
    

手順

  1. Dockerを入れる
  2. Docker 関連..

    Dockerfile
    FROM resin/rpi-raspbian:stretch
    
    ENV APT_CACHER_NG_CACHE_DIR=/var/cache/apt-cacher-ng \
        APT_CACHER_NG_LOG_DIR=/var/log/apt-cacher-ng \
        APT_CACHER_NG_USER=apt-cacher-ng
    
    RUN apt-get update && \
        DEBIAN_FRONTEND=noninteractive apt-get install -y apt-cacher-ng \
     && sed 's/# ForeGround: 0/ForeGround: 1/' -i /etc/apt-cacher-ng/acng.conf \
     && sed 's/# PassThroughPattern:.*this would allow.*/PassThroughPattern: .* #/' -i /etc/apt-cacher-ng/acng.conf \
     && rm -rf /var/lib/apt/lists/*
    
    COPY entrypoint.sh /sbin/entrypoint.sh
    RUN chmod 755 /sbin/entrypoint.sh
    
    EXPOSE 3142/tcp
    ENTRYPOINT ["/sbin/entrypoint.sh"]
    CMD ["/usr/sbin/apt-cacher-ng"]
    
    ビルド
    wget https://raw.githubusercontent.com/sameersbn/docker-apt-cacher-ng/master/entrypoint.sh
    sudo docker build -t mt08/docker-apt-cache-ng .
    
    実行
    cd ~
    sudo docker run -d -p 3142:3142 -v `pwd`/apt-cacher-ng:/var/cache/apt-cacher-ng mt08/docker-apt-cache-ng
    
    #
    echo 'Acquire::http::Proxy "http://localhost:3142";' | sudo tee /etc/apt/apt.conf.d/02proxy
    sudo apt update
    
    クライアント側設定(ホスト名は、各自変更)
    echo 'Acquire::http::Proxy "http://raspberrypi.local:3142";' | sudo tee /etc/apt/apt.conf.d/02proxy