Docker相关知识《Docker安装》

上一篇:用通俗的话说明Docker是什么

Docker安装


测试环境:Ubuntu 14.04 LTS x64位
所需工具:网络畅通

说明:Docker目前只能运行在64位平台上,内核不低于3.10,内核越新越好,过低的内核会导致Docker功能不稳定


1. 系统要求

检查自己的内核版本:

$ uname -a
Linux yc 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

或者

$ cat /proc/version
Linux version 3.13.0-24-generic (buildd@panlong) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014

2. 添加镜像源

首先需要安装apt-transport-https包支持HTTPS协议的源:

$ sudo apt-get install -y apt-transport-https

添加源的gpg密钥(密钥如果失效,请搜索获取):

$sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 
58118E89F3A912897C070ADBF76221572C52609D

Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.U27SLvpbiO --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
gpg: requesting key 2C52609D from hkp server p80.pool.sks-keyservers.net
gpg: key 2C52609D: public key "Docker Release Tool (releasedocker) " imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

添加Docker的官方apt软件源:

$ sudo cat < /etc/apt/sources.list.d/docker.list
deb https://apt.dockerproject.org/repo ubuntu-trusty main
EOF

添加成功后,更新apt软件包缓存

$ sudo apt-get update

3. 安装Docker

成功添加源后就可以安装最新版本的Docker了,软件包名为docker-engine

$ sudo apt-get install -y docker-engine

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  aufs-tools cgroup-lite git git-man liberror-perl libltdl7 libsystemd-journal0
Suggested packages:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arc
The following NEW packages will be installed:
  aufs-tools cgroup-lite docker-engine git git-man liberror-perl libltdl7 libsystemd-jour
0 upgraded, 8 newly installed, 0 to remove and 218 not upgraded.
Need to get 19.2 MB/22.3 MB of archives.
After this operation, 115 MB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu/ trusty-proposed/main libsystemd-journal0 amd64 20
Get:2 https://apt.dockerproject.org/repo/ ubuntu-trusty/main docker-engine amd64 17.05.0~
Fetched 19.2 MB in 20min 8s (15.9 kB/s)                                                  
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "zh_CN:zh",
	LC_ALL = (unset),
	LC_TIME = "zh_CN",
	LC_MONETARY = "zh_CN",
	LC_ADDRESS = "zh_CN",
	LC_TELEPHONE = "zh_CN",
	LC_NAME = "zh_CN",
	LC_MEASUREMENT = "zh_CN",
	LC_IDENTIFICATION = "zh_CN",
	LC_NUMERIC = "zh_CN",
	LC_PAPER = "zh_CN",
	LANG = "zh_CN.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package libltdl7:amd64.
(Reading database ... 55192 files and directories currently installed.)
Preparing to unpack .../libltdl7_2.4.2-1.7ubuntu1_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.2-1.7ubuntu1) ...
Selecting previously unselected package libsystemd-journal0:amd64.
Preparing to unpack .../libsystemd-journal0_204-5ubuntu20.25_amd64.deb ...
Unpacking libsystemd-journal0:amd64 (204-5ubuntu20.25) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1_amd64.deb ...
Unpacking aufs-tools (1:3.2+20130722-1.1) ...
Selecting previously unselected package docker-engine.
Preparing to unpack .../docker-engine_17.05.0~ce-0~ubuntu-trusty_amd64.deb ...
Unpacking docker-engine (17.05.0~ce-0~ubuntu-trusty) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../liberror-perl_0.17-1.1_all.deb ...
Unpacking liberror-perl (0.17-1.1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a1.9.1-1ubuntu0.7_all.deb ...
Unpacking git-man (1:1.9.1-1ubuntu0.7) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a1.9.1-1ubuntu0.7_amd64.deb ...
Unpacking git (1:1.9.1-1ubuntu0.7) ...
Selecting previously unselected package cgroup-lite.
Preparing to unpack .../cgroup-lite_1.9_all.deb ...
Unpacking cgroup-lite (1.9) ...
Processing triggers for man-db (2.6.7.1-1) ...
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Processing triggers for ureadahead (0.100.0-16) ...
Setting up libltdl7:amd64 (2.4.2-1.7ubuntu1) ...
Setting up libsystemd-journal0:amd64 (204-5ubuntu20.25) ...
Setting up aufs-tools (1:3.2+20130722-1.1) ...
Setting up docker-engine (17.05.0~ce-0~ubuntu-trusty) ...
docker start/running, process 11715
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:1.9.1-1ubuntu0.7) ...
Setting up git (1:1.9.1-1ubuntu0.7) ...
Setting up cgroup-lite (1.9) ...
cgroup-lite start/running
Processing triggers for libc-bin (2.19-0ubuntu6) ...
Processing triggers for ureadahead (0.100.0-16) ...

如果系统中存在较旧版本的Docker(lxc-docker),会提示是否先删除,选择“是”即可。

安装成功后,启动docker服务:

$ sudo service docker start

4. 检查docker服务,分ClientServer:

$ sudo docker version

Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:06 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:06 2017
 OS/Arch:      linux/amd64
 Experimental: false

至此Docker安装成功。

5.结束语

  • 见到新技术的时候,不要去怕深入,新技术的出现,肯定是因为有新需求的出现,新需求出现了,但原有的解决相应问题的解决方案不够用了,那么便会推进新的技术理论的出现和发展。
  • 不要为了学习新技术而学习新技术,因为如果没有具体的去使用新技术,是不那么容易理解的,从问题出发到解决方案和技术。
  • 搞不懂新技术是干什么的,要学会不求甚解,先学会用,然后再相辅相成的大胆猜测,小心求证。
  • 最后一句,干就完了,不怂。

下一篇:Docker相关知识《Docker常用命令》

你可能感兴趣的:(docker)