文档章节

Ubuntu安装Docker CE

ly6cyh
 ly6cyh
发布于 2017/08/06 11:26
字数 1790
阅读 102
收藏 0

To get started with Docker CE on Ubuntu, make sure you meet the prerequisites, then install Docker.

Prerequisites

Docker EE customers

To install Docker Enterprise Edition (Docker EE), go to Get Docker EE for Ubuntu instead of this topic.

To learn more about Docker EE, see Docker 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 on x86_64armhf, and s390x (IBM z Systems) architectures.

s390x limitations: System Z is only supported on Ubuntu Xenial and Zesty.

Uninstall old versions(先删除本地所有docker版本)

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them:

$ sudo apt-get remove docker docker-engine docker.io

It’s OK if apt-get reports 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 called docker-ce.

Recommended extra packages for Trusty 14.04(这是14.04才需要的,如果是高版本跳过这个步骤)

Unless you have a strong reason not to, install the linux-image-extra-* packages, which allow Docker to use the aufs storage 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 the overlay2 storage driver by default.

Install Docker CE

You can install Docker CE in different ways, depending on your needs:

  • Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.

  • Some users download the DEB package and install it manually and 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 automated convenience scripts to 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

  1. Update the apt package index:(先更新apt包)

    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:(安装支持https)

    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        software-properties-common
    
  3. 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 is 9DC8 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
    
  4. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below.(添加下载的repository)

    Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. 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 using Linux Mint Rafaela, you could use trusty.

    amd64:

  5. $ 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 the edge and test repositories.

    Learn about stable and edge channels.

INSTALL DOCKER CE

  1. Update the apt package index.(先更新apt包)

    $ sudo apt-get update
    
  2. 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 install or apt-get update command will always install the highest possible version, which may not be appropriate for your stability needs.

  3. 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版本,可以选择不同版本安装)

  4. $ 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.

  5. Verify that Docker CE is installed correctly by running the hello-world image.(运行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 use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

UPGRADE DOCKER CE(更新Docker-CE)

To upgrade Docker CE, first run sudo apt-get update, then follow the installation 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 .deb file for your release and install it manually. You will need to download a new file each time you want to upgrade Docker CE.

  1. Go to https://download.docker.com/linux/ubuntu/dists/, choose your Ubuntu version, browse to pool/stable/ and chooseamd64armhf, or s390x. Download the .deb file for the Docker version you want to install.(先下载程序包)

    Note: To install an edge package, change the word stable in the URL to edgeLearn about stable and edgechannels.

  2. 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.

  3. Verify that Docker CE is installed correctly by running the hello-world image.(运行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.

Docker CE is installed and running. You need to use sudo to run Docker commands. Continue to Post-installation steps for Linux to allow non-privileged users to run Docker commands and for other optional configuration steps.

UPGRADE DOCKER CE

To upgrade Docker CE, download the newer package file and repeat the installation procedure, pointing to the new file.

Install using the convenience script(第三种通过脚本安装方法)

Docker provides convenience scripts at get.docker.com and test.docker.com for installing stable and testing versions of Docker CE into development environments quickly and non-interactively. The source code for the scripts is in the docker-install repository.Using these scripts is not recommended for production environments, and you should understand the potential risks before you use them:

  • The scripts require root or sudo privileges in order to run. Therefore, you should carefully examine and audit the scripts before running them.
  • The scripts attempt to detect your Linux distribution and version and configure your package management system for you. In addition, the scripts do not allow you to customize any installation parameters. This may lead to an unsupported configuration, either from Docker’s point of view or from your own organization’s guidelines and standards.
  • The scripts install all dependencies and recommendations of the package manager without asking for confirmation. This may install a large number of packages, depending on the current configuration of your host machine.
  • Do not use the convenience script if Docker has already been installed on the host machine using another mechanism.

This example uses the script at get.docker.com to install the latest stable release of Docker CE on Linux. To install the latest testing version, use test.docker.com instead. In each of the commands below, replace each occurrence of get with test.

Warning:

Always examine scripts downloaded from the internet before running them locally.

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh

<output truncated>

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

Docker CE is installed. It starts automatically on DEB-based distributions. On RPM-based distributions, you need to start it manually using the appropriate systemctl or service command. As the message indicates, non-root users are not able to run Docker commands by default.

UPGRADE DOCKER AFTER USING THE CONVENIENCE SCRIPT

If you installed Docker using the convenience script, you should upgrade Docker using your package manager directly. There is no advantage to re-running the convenience script, and it can cause issues if it attempts to re-add repositories which have already been added to the host machine.

Uninstall Docker CE(卸载Docker CE)

  1. Uninstall the Docker CE package:

    $ sudo apt-get purge docker-ce
    
  2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

    $ sudo rm -rf /var/lib/docker
    

You must delete any edited configuration files manually.

本文转载自:https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu

ly6cyh

ly6cyh

粉丝 1
博文 11
码字总数 1733
作品 0
广州
技术主管
私信 提问
Ubuntu 16.04安装Docker CE

安装环境操作系统:Ubuntu Xenial 16.04 (LTS) Go语言版本:1.9.4 配置Ubuntu更新源(清华大学) 卸载旧版本的Docker 安装新版本的Docker 步骤一:安装必要的系统工具 步骤二:安装GPG证书 ...

FeanLau
2018/12/23
53
1
安装Docker和配置加速器(二)

一、 安装 docker-ce 1. 访问 https://opsx.alibaba.com/mirror 2. 打开这条URL: 二、Ubuntu 系统安装 Docker 1. 使用apt-get进行安装最新版本 1.1 安装必要的一些系统工具 root@ubuntu-18...

拿着保温瓶的年轻人
04/29
0
0
ubuntu16.04下docker的安装

可能是ubuntu系统的问题,我使用apt-get install docker-ce 安装失败 参考下面官方网站安装。 https://www.docker.com/community-edition 使用uGet下载docker安装deb包 https://download.doc...

liulangren0533
2018/07/06
0
0
centos 7 安装docker 并设置阿里云镜像仓库

centos 7 安装docker 并设置阿里云镜像仓库 yum install -y wget yum update yum install -y deltarpm =================================================================================......

zbill
2017/10/26
0
0
阿里云ECS服务器Ubuntu下安装docker-ce技巧

官方文档 先来份Ubuntu 下安装 docker 的官方文档 -> Get Docker CE for Ubuntu 官方文档的安装方式是最靠谱的,但是对于国内的小伙伴来说墙是硬伤... 国内安装技巧 先来看看2个镜像站: 阿里云...

taadis
2017/11/08
275
0

没有更多内容

加载失败,请刷新页面

加载更多

如何使用soapUI模拟webservice客户端发送请求

参考资料 https://jingyan.baidu.com/article/cbcede0712849a02f40b4d88.html 左边是请求参数,可以自己填写!按着那个绿色三角箭头可以模拟发送请求,右边是返回的报文 soapui如何发送xml格...

故久呵呵
42分钟前
5
0
Java Security 介绍

1.介绍 Java平台设计的重点是安全性。在其核心,java语言本身是类型安全的并且提供了垃圾自动回收,这使其增加了应用程序代码的健壮性。安全的类加载以及验证机制确保了只有合法的代码才能够...

lixiaobao
48分钟前
5
0
Niushop开源商城系统-分销商管理

分销商管理 1.分销员的招募与管理 如何申请成为分销员? 在wap端个人中心满足之前设置的升级条件,可以申请分销员 开启分销商审核,需要在后台分销商管理——》待审核处进行审核通过。 通过完...

niushop-芳
49分钟前
5
0
为什么大公司一定要使用 DevOps?

究竟什么是DevOps? 要想回答这个问题,首先要明确DevOps这个过程参与的人员是谁,即开发团队和IT运维团队。那么,DevOps的意图是什么呢?即在两个团队之间,建立良好的沟通和协作,更快更可靠...

cs平台
51分钟前
5
0
高危预警|RDP漏洞或引发大规模蠕虫爆发,用户可用阿里云免费检测服务自检,建议尽快修复

2019年9月6日,阿里云应急响应中心监测到Metasploit-framework官方在GitHub空间公开了针对Windows远程桌面服务远程命令执行漏洞(CVE-2019-0708)的利用代码。利用该代码,无需用户交互操作,即...

Mr_zebra
56分钟前
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部