在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Linux/ 在Docker中運(yùn)行Apt-Cacher-ng服務(wù)
docker用戶指南
鏡像
在Docker中運(yùn)行SSH進(jìn)程服務(wù)
Docker Hub
CentOS
Rackspace Cloud
Red Hat Enterprise Linux
在Docker中運(yùn)行Reids服務(wù)
FrugalWare
管理容器數(shù)據(jù)
Debian
Docker中運(yùn)行MongoDB
Gentoo
在Docker中使用Riak服務(wù)
IBM SoftLayer
在Docker中運(yùn)行Apt-Cacher-ng服務(wù)
開始使用Docker Hub
Amazon EC2
在Docker中運(yùn)行"hello Word"應(yīng)用
Docker Hub上的倉庫和鏡像
Ubuntu
Docker Hub賬戶
Docker中運(yùn)行Node.js web應(yīng)用
Docker中運(yùn)行CouchDB服務(wù)
Fedora
Binaries
CRUX Linux
使用Docker Hub
Mac OS X 安裝 Docker
在Docker中運(yùn)行PostgreSQL
創(chuàng)建一個(gè)基本鏡像
Docker Hub上的自動(dòng)化構(gòu)建
連接容器
Google Cloud Platform
使用docker第一步
使用docker鏡像
Arch Linux
openSUSE
使用容器
Microsoft Windows 安裝docker

在Docker中運(yùn)行Apt-Cacher-ng服務(wù)

注意:——如果你不喜歡sudo,可以查看非root用戶使用,--如何你使用OS X或者通過TCP使用Docker,你需要使用sudo

當(dāng)你有許多docker服務(wù)器,或者不能使用Docker緩存來構(gòu)建不相干的Docker容器,他可以為你的包緩存代理,這是非常有用的。該容器使第二個(gè)下載的任何包幾乎瞬間下載。

使用下邊的Dockerfile

    #
    # Build: docker build -t apt-cacher .
    # Run: docker run -d -p 3142:3142 --name apt-cacher-run apt-cacher
    #
    # and then you can run containers with:
    #   docker run -t -i --rm -e http_proxy http://dockerhost:3142/ debian bash
    #
    FROM        ubuntu
    MAINTAINER  SvenDowideit@docker.com

    VOLUME      ["/var/cache/apt-cacher-ng"]
    RUN     apt-get update ; apt-get install -yq apt-cacher-ng

    EXPOSE      3142
    CMD     chmod 777 /var/cache/apt-cacher-ng ; /etc/init.d/apt-cacher-ng start ; tail -f /var/log/apt-cacher-ng/*

使用下邊的命令構(gòu)建鏡像:

    $ sudo docker build -t eg_apt_cacher_ng .

現(xiàn)在運(yùn)行它,映射內(nèi)部端口到主機(jī)

    $ sudo docker run -d -p 3142:3142 --name test_apt_cacher_ng eg_apt_cacher_ng

查看日志文件,默認(rèn)使用tailed命令,你可以使用

    $ sudo docker logs -f test_apt_cacher_ng

讓你Debian-based容器使用代理,你可以做三件事之一:

1.添加一個(gè)apt代理設(shè)置echo 'Acquire::http { Proxy "http://dockerhost:3142"; };' >> /etc/apt/conf.d/01proxy

2.設(shè)置環(huán)境變量:http_proxy=http://dockerhost:3142/

3.修改你的sources.list來開始http://dockerhost:3142/

選項(xiàng)1注入是安全設(shè)置到你的apt配置在本地的公共基礎(chǔ)版本。

    FROM ubuntu
    RUN  echo 'Acquire::http { Proxy "http://dockerhost:3142"; };' >> /etc/apt/apt.conf.d/01proxy
    RUN apt-get update ; apt-get install vim git

    # docker build -t my_ubuntu .

選項(xiàng)2針對(duì)測(cè)試時(shí)非常好的,但是會(huì)破壞其它從http代理的HTTP客戶端,如curl 、wget或者其他:

    $ sudo docker run --rm -t -i -e http_proxy=http://dockerhost:3142/ debian bash

選項(xiàng)3是最輕便的,但是有時(shí)候你可能需要做很多次,你也可以在你的Dockerfile這樣做:

    $ sudo docker run --rm -t -i --volumes-from test_apt_cacher_ng eg_apt_cacher_ng bash

    $$ /usr/lib/apt-cacher-ng/distkill.pl
    Scanning /var/cache/apt-cacher-ng, please wait...
    Found distributions:
    bla, taggedcount: 0
         1. precise-security (36 index files)
         2. wheezy (25 index files)
         3. precise-updates (36 index files)
         4. precise (36 index files)
         5. wheezy-updates (18 index files)

    Found architectures:
         6. amd64 (36 index files)
         7. i386 (24 index files)

    WARNING: The removal action may wipe out whole directories containing
             index files. Select d to see detailed list.

    (Number nn: tag distribution or architecture nn; 0: exit; d: show details; r: remove tagged; q: quit): q

最后,停止測(cè)試容器,刪除容器,刪除鏡像:

    $ sudo docker stop test_apt_cacher_ng
    $ sudo docker rm test_apt_cacher_ng
    $ sudo docker rmi eg_apt_cacher_ng