docker 设计原理
1.何为docker?
三句话介绍:
Docker是一个开源的应用容器引擎,使用GO语言开发,基于Linux内核的cgroup,namespace,Union FS等技术,对应用程序进行封装隔离,并且独立于宿主机与其他进程,这种运行时封装的状态称为容器
Docker早起版本实现时基于LXC,并进一步对其进行封装,包括文件系统,网络互联,镜像管理等诸多方面进行了改进,极大的简化了容器管理。从0.7版本以后开始去掉了LXC,转为自行研发的libcontainer,从1.11版本开始,进一步演进为使用runC和containerd。
Docker的主要目标是“Build,Ship and Run Any App,Anywhere”,即通过对应用组件的封装,分发,部署,运行等生命周期的管理,达到应用组件级别的“一次封装,多次分发,到处部署".
四点总结:
- 使用最广泛的开源容器引擎
- 一种操作系统级别的虚拟技术
- 依赖linux内核特性:Namespace(资源隔离)和Cgroups(资源限制)
- 一个简单的应用程序打包工具
2.为何使用docker?
4点概括:
快速的交付和部署:使用docker,开发人员可以使用镜像来快速构建一套标准的开发环境;开发完成之后,测试和运维人员可以直接使用相同环境来部署代码。docker可以快速创建and删除容器,实现快速迭代,大量节约开发,测试,部署的时间,并且,各个步骤都有明确的配置和操作,整个过程可见,使团队更容易理解应用的创建和工作过程。
高效的利用资源:docker容器的运行不需要额外的虚拟化管理程序支持,只需要内核级别的虚拟化,可以实现更高的性能,同时对资源的额外需求很低。
轻松的迁移和扩展:几乎可以在任何平台之上运行,包括物理机,虚拟机,公有云,私有云,个人电脑等。这种兼容性可让用户在不同平台之间轻松地迁移应用。
简单的更新管理:使用Dockerfile,只需要修改配置,就可以替代以外大量的更新工作。并且所有的修改都以增量的方式进行分发和更新,从而实现自动化并且高效的容器管理。
下表是docker容器与传统虚拟机的特性比较
docker的设计目标:
1.提供简单的应用程序打包工具
2.开发人员和运维人员职责逻辑分离。(开发人员侧重点是如何使用docker部署应用程序,运维侧重点则是如果管理容器)
3.多环境保持一致性,消除了环境差异
3.docker的体系结构
C/S框架。Docker后台进程负责创建,运行和发布Docker容器。Docker客户端和后台进程可以运行在同一台机器上,也可以运行在不同的机器上,docker客户端通过sockets或者REST API与后台进程通讯。
Containerd:是一个简单的守护进程,使用runC管理容器。向DockerEngine提供接口。
Shim:负责管理一个容器。
runC:是一个轻量级的工具,只用来运行容器。
下图为docker的层级结构
docker整体工作流程:
1.clinet执行build,pull,run命令发送到DOCKER_HOST
2.DOCKER_HOST 的守护进程(docker_engine)创建容器
3.拉取镜像的时候,先从本地拉取,如果本地没有,回去镜像仓库拉取镜像
docker客户端
docker客户端是许多docker用户与docker进行交互的主要方式,是Docker最基本的用户接口,当使用docker run之类的命令时,客户端将这些命令发送到dockerd,dockerd执行这些命令。docker命令使用Docker API。另外,docker客户端可以与多个守护进程进行通信。
docker守护进程
docker的守护进程如上图所示,dockerd监听Docker API请求并管理对象(镜像,容器,网络和卷)。守护进程还可以与其他守护进程通信来管理docker鼓舞
Docker images
docker镜像类似于虚拟机镜像,可以将它理解为一个面向Docker引擎的只读模板,包含文件系统。
一个镜像可以包含一个完整的Ubuntu操作系统环境,可以把它称为一个Ubuntu镜像。镜像也可以安装apache应用程序,可以把它称为一个Apache镜像。
镜像时创建Docker 容器的基础,通过版本管理和增量的文件系统,Docker提供了一套十分简单的机制来创建和更新现有的镜像,用户甚至可以从网上下载一个已经做好的应用镜像,并通过简单的命令就可以直接使用。
Docker registers
docker仓库类似于代码仓库,是docker集中存放镜像文件的场所。
在这里说明一点,docker仓库和注册服务器不能混为一谈,注册服务器是存放仓库的地方,上面存放着多个仓库,每个仓库集中存放某一类镜像,往往包括多个镜像文件,通过不同的标签(tag)来进行区分。
docker仓库根据所存储的镜像公开与否,Docker仓库可以分为公开仓库(Public)和私有仓库(Private)两种形式。
Docker containers
docker容器类似于一个轻量的沙箱,Docker利用容器来运行和隔离应用。
容器时从镜像创建的应用运行实例,可以将其启动,开始,停止,删除,而这些容器都是相互隔离,互不可见的。
我们可以把容器看做时一个简易版的linux系统环境(包括root用户权限,进程空间,用户空间和网络空间等),以及运行在其中的应用程序打包而成的应用盒子。
镜像自身时只读的。容器从镜像启动的时候,Docker会在镜像的最上层创建一个可写层,如果需要安装软件,命令之类的会安装到可写成,但是镜像本身将保持不变。
docker注册中心
Docker 注册中心存储 Docker 镜像。Docker Hub 和 Docker Cloud 是任何人都可以使用的公共注册中心,并且 Docker 默认配置为在 Docker Hub 上查找镜像。你甚至可以运行你自己的私人注册中心。如果您使用 Docker Datacenter(DDC),它包括 Docker Trusted Registry(DTR)。
当您使用 docker pull
或 docker run
命令时,所需的镜像将从配置的注册中心中提取。当您使用 docker push
命令时,您的镜像将被推送到您配置的注册中心。
docker商店允许购买和销售 Docker 镜像或免费发布。例如,您可以购买包含来自软件供应商的应用程序或服务的 Docker 镜像,并使用该镜像将应用程序部署到您的测试,临时和生产环境中。您可以通过拉取新版本的镜像并重新部署容器来升级应用程序。
4.docker的核心技术
https://www.cnblogs.com/ylqh/p/10599831.html
5.虚拟化与docker比较?
虚拟化是一种资源管理技术,是将计算机的各种实体资源,如服务器,网络,内存以及存储等,予以抽象,转换后呈现出来,打破实体结构间的不可切割的障碍,使得用户可以用比原本的组态更好的方式来应用这些资源。
基于软件的虚拟化从对象所在的层次,又可以分为应用虚拟化和平台虚拟化(通常虚拟机技术即属于这个范畴)。其中,前者一般指的是一些模拟设备或者Wine这样的软件,后者可以分为一下几个子类:
完全虚拟化:虚拟机模拟完整底层硬件环境和特权指令的执行过程,客户操作系统无需进行更改。例如:vmware workstation ,VirtualBox,QEMU。
硬件辅助虚拟化:利用硬件(主要是cpu)辅助支持处理敏感指令来实现完全虚拟化的功能,客户操作系统无需更改,例如:vmware workstation/
部分虚拟化:只针对部分硬件资源进行虚拟化,客户操作系统需要进行修改,现在有些虚拟化技术的早起版本仅仅支持部分虚拟化
超虚拟化:部分硬件接口以软件的形式提供给客户机操作系统,客户操作系统需要进行修改,例如早起的Xen
操作系统级虚拟化:内核通过创建多个虚拟的操作系统实例(内核和库)来隔离不同的进程。容器相关的技术是这个范畴。例如:docker
docker虚拟化与传统虚拟化的不同之处:
6.docker的应用场景:
应用程序打包和发布
应用程序隔离
持续集成
部署微服务
快速搭建测试环境
提供PaaS产品(平台即服务)
7.docker的安装
首先我们要明确docker ce和docker ee的区别,docker ce是社区版本,docker ee 是商业版本,我们一般用docker ce版本足够了。
依据ubuntu16.04为例:
root@S1:~# apt-get update Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease [247 kB] Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates InRelease [109 kB] Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security InRelease [109 kB] Get:4 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main Sources [868 kB] Get:5 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe Sources [7,728 kB] Get:6 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 Packages [1,201 kB] Get:7 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main i386 Packages [1,196 kB] Get:8 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main Translation-en [568 kB] Get:9 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe amd64 Packages [7,532 kB] Get:10 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe i386 Packages [7,512 kB] Get:11 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe Translation-en [4,354 kB] Get:12 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main Sources [332 kB] Get:13 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/universe Sources [252 kB] Get:14 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 Packages [925 kB] Get:15 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main i386 Packages [807 kB] Get:16 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main Translation-en [372 kB] Get:17 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/universe amd64 Packages [740 kB] Get:18 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/universe i386 Packages [678 kB] Get:19 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/universe Translation-en [307 kB] Get:20 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/main Sources [144 kB] Get:21 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/universe Sources [103 kB] Get:22 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/main amd64 Packages [626 kB] Get:23 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/main i386 Packages [524 kB] Get:24 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/main Translation-en [259 kB] Get:25 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/universe amd64 Packages [430 kB] Get:26 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/universe i386 Packages [374 kB] Get:27 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security/universe Translation-en [173 kB] Fetched 38.5 MB in 6s (5,753 kB/s) Reading package lists... Done
安装apt-transport-https等软件包支持https协议的源:
root@S1:~# apt-get install apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common Reading package lists... Done Building dependency tree Reading state information... Done ca-certificates is already the newest version (20170717~16.04.2). curl is already the newest version (7.47.0-1ubuntu2.12). The following package was automatically installed and is no longer required: libopts25 Use 'apt autoremove' to remove it. The following additional packages will be installed: libassuan0 libnpth0 pinentry-curses python3-pycurl python3-software-properties unattended-upgrades Suggested packages: pinentry-doc libcurl4-gnutls-dev python-pycurl-doc python3-pycurl-dbg bsd-mailx The following NEW packages will be installed: gnupg-agent libassuan0 libnpth0 pinentry-curses python3-pycurl python3-software-properties software-properties-common unattended-upgrades The following packages will be upgraded: apt-transport-https upgraded, 8 newly installed, 0 to remove and 28 not upgraded. Need to get 445 kB of archives. After this operation, 2,001 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 apt-transport-https amd64 1.2.31 [26.6 kB] Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libassuan0 amd64 2.4.2-2 [34.6 kB] Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 pinentry-curses amd64 0.9.7-3 [31.2 kB] Get:4 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libnpth0 amd64 1.2-3 [7,998 B] Get:5 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 gnupg-agent amd64 2.1.11-6ubuntu2.1 [240 kB] Get:6 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 python3-pycurl amd64 7.43.0-1ubuntu1 [42.3 kB] Get:7 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 python3-software-properties all 0.96.20.8 [20.2 kB] Get:8 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 software-properties-common all 0.96.20.8 [9,440 B] Get:9 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 unattended-upgrades all 0.90ubuntu0.10 [32.3 kB] Fetched 445 kB in 0s (937 kB/s) Preconfiguring packages ... (Reading database ... 100364 files and directories currently installed.) Preparing to unpack .../apt-transport-https_1.2.31_amd64.deb ... Unpacking apt-transport-https (1.2.31) over (1.2.29ubuntu0.1) ... Selecting previously unselected package libassuan0:amd64. Preparing to unpack .../libassuan0_2.4.2-2_amd64.deb ... Unpacking libassuan0:amd64 (2.4.2-2) ... Selecting previously unselected package pinentry-curses. Preparing to unpack .../pinentry-curses_0.9.7-3_amd64.deb ... Unpacking pinentry-curses (0.9.7-3) ... Selecting previously unselected package libnpth0:amd64. Preparing to unpack .../libnpth0_1.2-3_amd64.deb ... Unpacking libnpth0:amd64 (1.2-3) ... Selecting previously unselected package gnupg-agent. Preparing to unpack .../gnupg-agent_2.1.11-6ubuntu2.1_amd64.deb ... Unpacking gnupg-agent (2.1.11-6ubuntu2.1) ... Selecting previously unselected package python3-pycurl. Preparing to unpack .../python3-pycurl_7.43.0-1ubuntu1_amd64.deb ... Unpacking python3-pycurl (7.43.0-1ubuntu1) ... Selecting previously unselected package python3-software-properties. Preparing to unpack .../python3-software-properties_0.96.20.8_all.deb ... Unpacking python3-software-properties (0.96.20.8) ... Selecting previously unselected package software-properties-common. Preparing to unpack .../software-properties-common_0.96.20.8_all.deb ... Unpacking software-properties-common (0.96.20.8) ... Selecting previously unselected package unattended-upgrades. Preparing to unpack .../unattended-upgrades_0.90ubuntu0.10_all.deb ... Unpacking unattended-upgrades (0.90ubuntu0.10) ... Processing triggers for libc-bin (2.23-0ubuntu11) ... Processing triggers for man-db (2.7.5-1) ... Processing triggers for dbus (1.10.6-1ubuntu3.3) ... Processing triggers for systemd (229-4ubuntu21.16) ... Processing triggers for ureadahead (0.100.0-19) ... Setting up apt-transport-https (1.2.31) ... Setting up libassuan0:amd64 (2.4.2-2) ... Setting up pinentry-curses (0.9.7-3) ... Setting up libnpth0:amd64 (1.2-3) ... Setting up gnupg-agent (2.1.11-6ubuntu2.1) ... Setting up python3-pycurl (7.43.0-1ubuntu1) ... Setting up python3-software-properties (0.96.20.8) ... Setting up software-properties-common (0.96.20.8) ... Setting up unattended-upgrades (0.90ubuntu0.10) ... Creating config file /etc/apt/apt.conf.d/50unattended-upgrades with new version Synchronizing state of unattended-upgrades.service with SysV init with /lib/systemd/systemd-sysv-install... Executing /lib/systemd/systemd-sysv-install enable unattended-upgrades Processing triggers for libc-bin (2.23-0ubuntu11) ... Processing triggers for dbus (1.10.6-1ubuntu3.3) ... Processing triggers for systemd (229-4ubuntu21.16) ... Processing triggers for ureadahead (0.100.0-19) ... #添加源的gpg密钥 root@S1:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo: unable to resolve host S1 OK
#确认导入指纹为“9DC8...CD88”的GPG公钥 root@S1:~# apt-key fingerprint 0EBFCD88 pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid Docker Release (CE deb) <docker@docker.com> sub 4096R/F273FCD8 2017-02-22 #添加Docker稳定版的官方软件源,非xenial版本的系统注意修改为自己对应的代号 root@S1:~# add-apt-repository \ > "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ > $(lsb_release -cs) \ > stable" root@S1:~# apt-get update Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates InRelease Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security InRelease Get:4 https://download.docker.com/linux/ubuntu xenial InRelease [66.2 kB] Get:5 https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages [7,361 B] Fetched 73.6 kB in 1s (38.0 kB/s) Reading package lists... Done
安装docker社区版
如果指定版本:apt install docker-ce=18.06.3~ce~3-0~ubuntu
root@S1:~# apt-get install docker-ce docker-ce-cli containerd.io Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libopts25 Use 'apt autoremove' to remove it. The following additional packages will be installed: aufs-tools cgroupfs-mount git git-man liberror-perl libltdl7 pigz Suggested packages: mountall git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn The following NEW packages will be installed: aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli git git-man liberror-perl libltdl7 pigz upgraded, 10 newly installed, 0 to remove and 28 not upgraded. Need to get 54.4 MB of archives. After this operation, 269 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe amd64 pigz amd64 2.3.1-2 [61.1 kB] Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB] Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe amd64 cgroupfs-mount all 1.2 [4,970 B] Get:4 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB] Get:5 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.6 [736 kB] Get:6 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.6 [3,176 kB] Get:7 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 libltdl7 amd64 2.4.6-0.1 [38.3 kB] Get:8 https://download.docker.com/linux/ubuntu xenial/stable amd64 containerd.io amd64 1.2.4-1 [19.9 MB] Get:9 https://download.docker.com/linux/ubuntu xenial/stable amd64 docker-ce-cli amd64 5:18.09.3~3-0~ubuntu-xenial [13.0 MB] Get:10 https://download.docker.com/linux/ubuntu xenial/stable amd64 docker-ce amd64 5:18.09.3~3-0~ubuntu-xenial [17.4 MB] Fetched 54.4 MB in 11min 52s (76.4 kB/s) Selecting previously unselected package pigz. (Reading database ... 100461 files and directories currently installed.) Preparing to unpack .../pigz_2.3.1-2_amd64.deb ... Unpacking pigz (2.3.1-2) ... Selecting previously unselected package aufs-tools. Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1ubuntu1_amd64.deb ... Unpacking aufs-tools (1:3.2+20130722-1.1ubuntu1) ... Selecting previously unselected package cgroupfs-mount. Preparing to unpack .../cgroupfs-mount_1.2_all.deb ... Unpacking cgroupfs-mount (1.2) ... Selecting previously unselected package containerd.io. Preparing to unpack .../containerd.io_1.2.4-1_amd64.deb ... Unpacking containerd.io (1.2.4-1) ... Selecting previously unselected package docker-ce-cli. Preparing to unpack .../docker-ce-cli_5%3a18.09.3~3-0~ubuntu-xenial_amd64.deb ... Unpacking docker-ce-cli (5:18.09.3~3-0~ubuntu-xenial) ... Selecting previously unselected package docker-ce. Preparing to unpack .../docker-ce_5%3a18.09.3~3-0~ubuntu-xenial_amd64.deb ... Unpacking docker-ce (5:18.09.3~3-0~ubuntu-xenial) ... Selecting previously unselected package liberror-perl. Preparing to unpack .../liberror-perl_0.17-1.2_all.deb ... Unpacking liberror-perl (0.17-1.2) ... Selecting previously unselected package git-man. Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.6_all.deb ... Unpacking git-man (1:2.7.4-0ubuntu1.6) ... Selecting previously unselected package git. Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.6_amd64.deb ... Unpacking git (1:2.7.4-0ubuntu1.6) ... Selecting previously unselected package libltdl7:amd64. Preparing to unpack .../libltdl7_2.4.6-0.1_amd64.deb ... Unpacking libltdl7:amd64 (2.4.6-0.1) ... Processing triggers for man-db (2.7.5-1) ... Processing triggers for libc-bin (2.23-0ubuntu11) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for systemd (229-4ubuntu21.16) ... Setting up pigz (2.3.1-2) ... Setting up aufs-tools (1:3.2+20130722-1.1ubuntu1) ... Setting up cgroupfs-mount (1.2) ... Setting up containerd.io (1.2.4-1) ... Setting up docker-ce-cli (5:18.09.3~3-0~ubuntu-xenial) ... Setting up docker-ce (5:18.09.3~3-0~ubuntu-xenial) ... update-alternatives: using /usr/bin/dockerd-ce to provide /usr/bin/dockerd (dockerd) in auto mode Setting up liberror-perl (0.17-1.2) ... Setting up git-man (1:2.7.4-0ubuntu1.6) ... Setting up git (1:2.7.4-0ubuntu1.6) ... Setting up libltdl7:amd64 (2.4.6-0.1) ... Processing triggers for libc-bin (2.23-0ubuntu11) ... Processing triggers for systemd (229-4ubuntu21.16) ... Processing triggers for ureadahead (0.100.0-19) ... root@S1:~# docker version Client: Version: 18.09.3 API version: 1.39 Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 06:40:58 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.3 API version: 1.39 (minimum version 1.12) Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 05:59:55 2019 OS/Arch: linux/amd64 Experimental: false root@S1:~# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
除了以上的手安装方法,也可以使用官方提供的脚本来自动化安装Docker:
curl -sSL https://get.docker.com | sh
如果安装其他版本,请指定版本号安装即可