You can get the /etc/apt-cacher/apt-cacher.conf from an ubuntu system after installing the apt-cacher package.
#
# example ubuntu 14.04 apt-cacher
#
FROM ubuntu:14.04
MAINTAINER championofcyrodiil.blogspot.com
USER root
RUN apt-get update
RUN apt-get -y -q install apt-cacher
ADD apt-cacher.conf /etc/apt-cacher/apt-cacher.conf
ADD start-cacher.sh /root/start-cacher.sh
RUN chmod +x /root/start-cacher.sh
EXPOSE 3142
#Default Docker Run Comamnd(s)
CMD ["/root/start-cacher.sh"]
And of course, the 'start-cacher.sh' bash script. Make sure it has been chmod +x so it's executable.
#!/bin/bash
/usr/sbin/apt-cacher -R 3 -d -p /var/run/apt-cacher.pid
tail -f /var/log/apt-cacher/access.log
wait
Once that is done, you will want to place all three files in to a single folder, cd to that folder and build the docker image, here is my example:
$ sudo docker build -t local:apt-cacher .
Note the period at the end to specify the context of the current directory with the scripts. Next it is time to run the container, make sure the host (-h) matches the daemon listening host specified in /etc/apt-cacher/apt-cacher.conf.
$ sudo docker run -d -p 3142:3142 -h apt-cacher local:apt-cacher
$ sudo docker ps -sl
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
7b6a7ff25691 local:apt-cacher /root/start-cacher.s 18 hours ago Up 18 hours 0.0.0.0:3142->3142/tcp clever_hoover 361.4 MB
For client systems to use the proxy, add the file /etc/apt/apt.conf.d/01proxy with the contents:
Acquire::http::Proxy "http://$DOCKERHOST
Like so,
$ sudo echo 'Acquire::http::Proxy "http://:3142";' >> /etc/apt/apt.conf.d/01proxy
No comments:
Post a Comment