Docker configuration Cache Proxy service Apt-cacher-ng

Source: Internet
Author: User
Tags docker run linux mint

Apt-cacher-ng is a caching proxy service (or apt proxy) for Debian-based devices such as Ubuntu, Kubuntu, Xubuntu, Edubuntu, Linux mint, etc., which is used to cache packages that have already been downloaded.

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/8F/58/wKioL1jbgyzxjb9AAAFjNQixMhc202.png "title=" Ng.png "alt=" Wkiol1jbgyzxjb9aaafjnqixmhc202.png "/>

You have a few computers linked to the network, you want to manually install or update the package on each machine, (imagine) this is a rather difficult task and time-consuming; that's why we have to configure a Apt-cacher-ng service to all systems this great idea, Since it will cache all downloaded packages from the network for the first time to Apt-cache server, the remaining Debian, Ubuntu machines get these packages just from Apt-cache directly, which will save us valuable time and network bandwidth.

Characteristics

    1. Apt-cacher-ng will save us time.

    2. Apt-cacher-ng will save our bandwidth.

    3. By importing the parameters, we can integrate the ISO image data or DVD to Apt-cacher-ng.

This experiment uses Docker containers to build:

1, first create the Dockerfile file,

[Email protected]:~/docker/apt-cache-ng# cat Dockerfile from Ubuntuvolume ["/var/cache/apt-cacher-ng"]run Apt-get update && apt-get install-y apt-cacher-ngexpose 3142CMD chmod 777/var/cache/apt-cacher-ng & &/etc/init.d/apt-cacher-ng start && tail-f/var/log/apt-cacher-ng/*

2. Build this image

Docker build-t Eg_apt_cache_ng.

3. Boot the image and map the port to 13142 on the host

Docker run-d-P 13142:3142--name test_apt_cacher_ng eg_apt_cacher_ng

4. You can use the Docker command to view the log

Docker Logs-f Test_apt_cacher_ng

5, login browser view;

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8F/59/wKioL1jbhV6htjA_AAEZZsPnZ_8744.png-wh_500x0-wm_ 3-wmp_4-s_3154276963.png "title=" Ng2.png "alt=" Wkiol1jbhv6htja_aaezzspnz_8744.png-wh_50 "/>

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/8F/5B/wKiom1jbhZLBIRp4AAB6E_3pxtY989.png "title=" Ng3.png "alt=" Wkiom1jbhzlbirp4aab6e_3pxty989.png "/>

Here, we can see the Apt-cacher-ng report page, click on the static report, configure the bottom of the page, navigate to the download hit or error situation page.

On the report page we need to copy the proxy URL for use behind. We can install packages on this server, by configuring local parameters, adding entity/etc/apt/apt.conf.d/02proxy apt-cache.

acquire::http {Proxy "http://192.168.0.2:3142";};

Description of the Docker website:

to Get your debian-based containers to use the proxy and you have following options. Note that you must replace test_apt_cacher_ng  container.

  1. Add an apt Proxy settingecho ‘Acquire::http { Proxy "http://dockerhost:3142"; };‘ >> /etc/apt/conf.d/01proxy

  2. Set an environment variable:http_proxy=http://dockerhost:3142/

  3. Change your sources.list entries to start withhttp://dockerhost:3142/

  4. Link debian-based containers to the APT proxy container using--link

  5. Create a custom network of a APT proxy container with debian-based containers.


6. Create a Docker container for the client

Docker run--rm-t-i-e Http_proxy=http://192.168.0.2:3142/debian bash

You can also use Dockerfile to specify

From Ubunturun Echo ' acquire::http {Proxy "http://192.168.0.2:3142";}; ' >>/etc/apt/apt.conf.d/01proxyrun Apt-ge T update && apt-get install-y vim git

Link container to apt container

Docker run-i-T--link test_apt_cacher_ng:apt_proxy-e Http_proxy=http://apt_proxy:3142/debian Bash

You can also create a container yourself and then go into the container to manually configure

Vim/etc/apt/apt.conf.d/02proxy #在这个路径下创建文件 acquire::http {Proxy "http://192.168.0.2:3142";}; #写入这条内容

7. Test:

All over our server and client are installed.

[email protected]:~/docker/apt-cache-ng# docker pscontainer id         IMAGE                COMMAND                   created             status               PORTS                       namesbd4e542edb39        debian                "Bash"                     59 minutes ago       up 59 minutes                                  peaceful_ pikef6fafb226c66        eg_apt_cache_ng      " /bin/sh -c  ' chmod ... '    About an hour ago   Up  About an hour    0.0.0.0:13142->3142/tcp   test_apt_cacher_ng

Log in to the client, go to update several packages, or install a few packages, and then the Web can see how many files are cached

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8F/5B/wKiom1jbiEHj0jmLAAB_TOIoztc228.png-wh_500x0-wm_ 3-wmp_4-s_217333815.png "title=" Ng4.png "alt=" Wkiom1jbiehj0jmlaab_toioztc228.png-wh_50 "/>

Here you can put the installation package, uninstall, and then install again, you will find that the speed will be very fast, and the web will be hits will also have a change to show whether you download from apt



Official website: https://www.unix-ag.uni-kl.de/~bloch/acng/html/index.html

Docker official website: https://docs.docker.com/engine/examples/apt-cacher-ng/

Reference post: HTTP://LIUHONG1HAPPY.LOFTER.COM/POST/1CDB27C8_60DFC24


This article from the "Circle of a Bird" blog, reproduced please contact the author!

Docker configuration Cache Proxy service Apt-cacher-ng

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.