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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM