|
To get started with Docker CE on Ubuntu,make sure youmeet the prerequisites,theninstall Docker.
Prerequisites
Docker EE customers
To install Docker Enterprise Edition (Docker EE),go toGet Docker EE for Ubuntuinstead of this topic.
To learn more about Docker EE,seeDocker Enterprise Edition.
OS requirements
To install Docker CE,you need the 64-bit version of one of these Ubuntu versions:
- Zesty 17.04
- Xenial 16.04 (LTS)
- Trusty 14.04 (LTS)
Docker CE is supported on Ubuntu onx86_64,armhf,ands390x(IBM z Systems) architectures.
s390xlimitations: System Z is only supported on Ubuntu Xenial and Zesty.
Uninstall old versions(先删除本地所有docker版本)
Older versions of Docker were calleddockerordocker-engine. If these are installed,uninstall them:
$ sudo apt-get remove docker docker-engine docker.io
It’s OK ifapt-getreports that none of these packages are installed.
The contents of/var/lib/docker/,including images,containers,volumes,and networks,are preserved. The Docker CE package is now calleddocker-ce.
Recommended extra packages for Trusty 14.04(这是14.04才需要的,如果是高版本跳过这个步骤)
Unless you have a strong reason not to,install thelinux-image-extra-*packages,which allow Docker to use theaufsstorage drivers.
$ sudo apt-get update
$ sudo apt-get install
linux-image-extra-$(uname -r)
linux-image-extra-virtual
For Ubuntu 16.04 and higher,the Linux kernel includes support for OverlayFS,and Docker CE will use theoverlay2storage driver by default.
Install Docker CE
You can install Docker CE in different ways,depending on your needs:
-
Most usersset up Docker’s repositoriesand install from them,for ease of installation and upgrade tasks. This is the recommended approach.
-
Some users download the DEB package andinstall it manuallyand manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.
-
In testing and development environments,some users choose to use automatedconvenience scriptsto install Docker.
Install using the repository(第一种通过repository安装)
Before you install Docker CE for the first time on a new host machine,you need to set up the Docker repository. Afterward,you can install and update Docker from the repository.
SET UP THE REPOSITORY
-
Update theaptpackage index:(先更新apt包) $ sudo apt-get update
-
Install packages to allowaptto use a repository over HTTPS:(安装支持https) $ sudo apt-get install
apt-transport-https
ca-certificates
curl
software-properties-common
-
Add Docker’s official GPG key:(添加docker的GPG,直到返回OK才成功) $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - Verify that the key fingerprint is9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88. $ sudo 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
-
Use the following command to set up thestablerepository. You always need thestablerepository,even if you want to install builds from theedgeortestrepositories as well. To add theedgeortestrepository,add the wordedgeortest(or both) after the wordstablein the commands below.(添加下载的repository)
Note: Thelsb_release -cssub-command below returns the name of your Ubuntu distribution,such asxenial. Sometimes,in a distribution like Linux Mint,you might have to change$(lsb_release -cs)to your parent Ubuntu distribution. For example,if you are usingLinux Mint Rafaela,you could usetrusty.
amd64:
-
$ sudo add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(lsb_release -cs)
stable" armhf: $ sudo add-apt-repository
"deb [arch=armhf] https://download.docker.com/linux/ubuntu
$(lsb_release -cs)
stable" s390x: $ sudo add-apt-repository
"deb [arch=s390x] https://download.docker.com/linux/ubuntu
$(lsb_release -cs)
stable"
Note: Starting with Docker 17.06,stable releases are also pushed to theedgeandtestrepositories.
Learn aboutstableandedgechannels.
INSTALL DOCKER CE
-
Update theaptpackage index.(先更新apt包) $ sudo apt-get update
-
Install the latest version of Docker CE,or go to the next step to install a specific version. Any existing installation of Docker is replaced.(安装docker-ce) $ sudo apt-get install docker-ce
Got multiple Docker repositories?
If you have multiple Docker repositories enabled,installing or updating without specifying a version in theapt-get installorapt-get updatecommand will always install the highest possible version,which may not be appropriate for your stability needs.
-
On production systems,you should install a specific version of Docker CE instead of always using the latest. This output is truncated. List the available versions.(查看本地docker-ce版本,可以选择不同版本安装)
-
$ apt-cache madison docker-ce
docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages The contents of the list depend upon which repositories are enabled. Choose a specific version to install. The second column is the version string. The third column is the repository name,which indicates which repository the package is from and by extension its stability level. To install a specific version,append the version string to the package name and separate them by an equals sign (=):(指定安装某一个版本) $ sudo apt-get install docker-ce=<VERSION> The Docker daemon starts automatically.
-
Verify that Docker CE is installed correctly by running thehello-worldimage.(运行hello-world例子,第一句话输出:“Hello from Docker!”就标识成功了) $ sudo docker run hello-world or if you run on armhf:
bash $ sudo docker run armhf/hello-world
This command downloads a test image and runs it in a container. When the
container runs,it prints an informational message and exits.
Docker CE is installed and running. You need to usesudoto run Docker commands. Continue toLinux postinstallto allow non-privileged users to run Docker commands and for other optional configuration steps.
UPGRADE DOCKER CE(更新Docker-CE)
To upgrade Docker CE,first runsudo apt-get update,then follow theinstallation instructions,choosing the new version you want to install.
Install from a package(第二种通过离线程序包安装方法)
If you cannot use Docker’s repository to install Docker CE,you can download the.debfile for your release and install it manually. You will need to download a new file each time you want to upgrade Docker CE.
-
Go tohttps://download.docker.com/linux/ubuntu/dists/,choose your Ubuntu version,browse topool/stable/and chooseamd64,ors390x. Download the.debfile for the Docker version you want to install.(先下载程序包)
Note: To install anedgepackage,change the wordstablein the URL toedge.Learn aboutstableandedgechannels.
-
Install Docker CE,changing the path below to the path where you downloaded the Docker package.(执行安装) $ sudo dpkg -i /path/to/package.deb The Docker daemon starts automatically.
-
Verify that Docker CE is installed correctly by running thehello-worldimage.(运行hello-world例子) $ sudo docker run hello-world This command downloads a test image and runs it in a container. When the container runs,it prints an informational message and exits.
(编辑:安卓应用网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|