docker容器的ubuntu系统中设置apt-get代理和apt-get源
docker容器的ubuntu系统中设置apt-get代理安装软件
有时候虚拟机不能安装软件,需要设置代理才能正常连接网络安装软件
Ubuntu中给apt-get设置代理
进入docker-haproxy服务
docker exec -it h1 /bin/bash
编辑文件: /etc/apt/apt.conf
在您的apt.conf文件中加入下面这行(根据你的实际情况替换yourproxyaddress和proxyport)
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Acquire::https::proxy "http://yourproxyaddress:proxyport";
Acquire::http::Proxy "http://10.11.0.148:808";
Acquire::https::proxy "http://10.11.0.148:808";
容器没有编辑器,只能通过echo写入的方式设置代理
设置apt-get的代理
cd /etc/apt
echo 'Acquire::http::Proxy "http://10.11.0.148:808";' >> apt.conf
echo 'Acquire::https::proxy "http://10.11.0.148:808";' >> apt.conf
或者
cd /etc/apt/apt.conf.d
echo 'Acquire::http::Proxy "http://10.11.0.148:808";' >> proxy.conf
echo 'Acquire::https::proxy "http://10.11.0.148:808";' >> proxy.conf
# 系统升级,安装vim编辑器
# apt-get update
root@f9ee51b26ac0:/etc/apt/apt.conf.d# apt-get install vim
# 安装keepalived和ping命令
apt-get install keepalived
apt-get install net-tools
apt-get install iputils-pinp
aliyun的镜像站
https://developer.aliyun.com/mirror/
ubuntu的香港中文大学源,如果是香港线路可以设置如下
deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty main restricted universe multiverse
deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-security main restricted universe multiverse
deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-updates main restricted universe multiverse
deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty main restricted universe multiverse
deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-backports main restricted universe multiverse
报错
W: GPG error: http://ftp.cuhk.edu.hk/pub/Linux/ubuntu trusty Release:
解决:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 出现的字符串
# apt-get update
# 安装软件
apt-get install iputils-ping --allow-unauthenticated -y
cd /usr/redis/src/
./redis-server ../redis.conf