【玩转Docker系列2】Docker安装
Docker安装
操作系统准备
Docker当前支持不同类型不同版本的操作系统,其具体配套关系详见官方文档:https://docs.docker.com/engine/installation/。安装前确保已准备了满足Docker安装的一台操作系统。
备注:本文所有示例都是基于Ubuntu 14.04,后面不再对操作系统版本进行重复说明。
UbuntuTest:~ # uname -ar Linux UbuntuTest 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux |
网络配置
Ubuntu系统安装Docker以及Docker在使用过程中如从公共仓库下载镜像,都需要配置操作系统的外网权限,Ubuntu系统的具体配置如下(网络配置完成后需要重启生效):
UbuntuTest:~ # cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).
# The loopback network interface auto lo iface lo inet loopback
# The primary network interface auto eth0 iface eth0 inet static address 10.71.96.200 netmask 255.255.255.0 gateway 10.71.96.1 dns-nameservers 10.98.48.39 dns-search huawei.com 备注:如上配置最后两行为添加公司可用的域名服务器。
UbuntuTest:~ # ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:50:56:84:a4:3c brd ff:ff:ff:ff:ff:ff inet 10.71.96.200/24 brd 10.71.96.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::250:56ff:fe84:a43c/64 scope link valid_lft forever preferred_lft forever |
添加网络代理的环境变量,当前系统中结果如下:
UbuntuTest:~ # tail -n 2 /root/.bashrc export http_proxy="http://username:password@proxy.huawei.com:8080" export https_proxy="http://username:password@proxy.huawei.com:8080" 备注:username为域帐号,password为域帐号密码,密码不能带“@”字符。
UbuntuTest:~ # source /root/.bashrc UbuntuTest:~ # env |grep http http_proxy=http://username:password @proxy.huawei.com:8080 https_proxy=http://username:password @proxy.huawei.com:8080 UbuntuTest:~ # curl www.google.com >/dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 7237 100 7237 0 0 80829 0 --:--:-- --:--:-- --:--:-- 81314 UbuntuTest:~ # echo $? 0 |
Docker如需从官网拉镜像还需要进行如下配置(该配置文件在Docker安装后才有):
UbuntuTest:~ # cat /etc/default/docker # If you need Docker to use an HTTP proxy, it can also be specified here. #export http_proxy="http://127.0.0.1:3128/"
export http_proxy="http://username:password@proxy.huawei.com:8080" export https_proxy="http://username:password@proxy.huawei.com:8080" |
- 点赞
- 收藏
- 关注作者
评论(0)