使用docker搭建debian软件源镜像服务器

准备:docker镜像debian:latest

运行docker:

docker run -it -w /home/debian_source/mirror -w /home/debian_source/skel -w /home/debian_source/var -v /opt/debian_source:/home/debian_source -p 0.0.0.0:6868:80 --name debianMirror debian:latest

第一步、安装apt-mirror工具

apt-get install -y vim apache2 apt-mirror 

第二步、配置apt-mirror,修改/etc/apt/mirror.list

set base_path     /home/debian_source
set mirror_path  $base_path/mirror
set skel_path    $base_path/skel
set var_path     $base_path/var
set cleanscript $var_path/clean.sh
set defaultarch  <running host architecture>
set nthreads     3    #可以设置为小一点数字为3,防止网络拥挤
deb-i386 http://ftp.us.debian.org/debian jessie main contrib non-free
deb-amd64 http://ftp.us.debian.org/debian jessie main contrib non-free
deb-i386 http://security.debian.org/ jessie/updates main contrib non-free
deb-amd64 http://security.debian.org/ jessie/updates main contrib non-free

clean http://ftp.us.debian.org/debian
clean http://security.debian.org/
 

第三步、同步镜像

# apt-mirror

等待几个小时,大概90G左右。期间直接退出终端,不要关闭docker容器,如果想再次进入使用:

docker exec -it 容器ID /bin/bash
第四步、http访问镜像-服务器镜像设置

修改apatch2的配置文件/etc/apache2/sites-enabled/000-default,把DocumentRoot /var/www改为:

DocumentRoot /home/debian_source/mirror/ftp.us.debian.org/debian

然后重启apache:

/etc/init.d/apache2 restart

第五步、client访问设置:

修改sources.list

vim /etc/apt/sources.list

添加:

deb http://服务器ip地址 jessie main contrib non-free

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值