【玩转Docker系列2】Docker安装

举报
fengfeng 发表于 2017/03/08 00:01:13 2017/03/08
【摘要】 Docker当前支持不同类型不同版本的操作系统,其具体配套关系详见官方文档:https://docs.docker.com/engine/installation/。安装前确保已准备了满足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"

作者 | 胡国胜

转载请注明出处:华为云博客 https://portal.hwclouds.com/blogs

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200