加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Ubuntu > 正文

ubuntu docker 安装

发布时间:2020-05-22 16:06:44 所属栏目:Ubuntu 来源:互联网
导读:Install Docker on Ubuntu Estimated reading time:17 minutes Docker is supported on these Ubuntu operating systems: Ubuntu Xenial 16.04 (LTS) Ubuntu Wily 15.10 Ubuntu Trusty 14.04 (LTS) Ubuntu Precise

Install Docker on Ubuntu

Estimated reading time:17 minutes

Docker is supported on these Ubuntu operating systems:

  • Ubuntu Xenial 16.04 (LTS)

  • Ubuntu Wily 15.10

  • Ubuntu Trusty 14.04 (LTS)

  • Ubuntu Precise 12.04 (LTS)

This page instructs you to install Docker on Ubuntu,using packages provided by Docker. Using these packages ensures you get the latest official release of Docker. If you are required to install using Ubuntu-managed packages,consult the Ubuntu documentation. Some files and commands may be different if you use Ubuntu-managed packages.

Note: Ubuntu Utopic 14.10 and 15.04 exist in Docker’sAPTrepository but are no longer officially supported.

Prerequisites

Docker has two important installation requirements:

  • Docker only works on a 64-bit Linux installation.

  • Docker requires version 3.10 or higher of the Linux kernel. Kernels older than 3.10 lack some of the features required to run Docker containers and contain known bugs which cause data loss and frequently panic under certain conditions.

    To check your current kernel version,open a terminal and useuname -rto display your kernel version:

    $uname-r3.11.0-15-generic

Update your apt sources

To setAPTto use packages from the Docker repository:

  1. Log into your machine as a user withsudoorrootprivileges.

  2. Open a terminal window.

  3. Update package information,ensure that APT works with thehttpsmethod,and that CA certificates are installed.

    $sudoapt-getupdate$sudoapt-getinstallapt-transport-httpsca-certificates
  4. Add the newGPGkey. This commands downloads the key with the ID58118E89F3A912897C070ADBF76221572C52609Dfrom the keyserverhkp://ha.pool.sks-keyservers.net:80and adds it to theadvkeychain. For more info,see the output ofman apt-key.

    $sudoapt-keyadv
    --keyserverhkp://ha.pool.sks-keyservers.net:80
    --recv-keys58118E89F3A912897C070ADBF76221572C52609D
  5. Find the entry in the table below which corresponds to your Ubuntu version. This determines where APT will search for Docker packages. When possible,run a long-term support (LTS) edition of Ubuntu.

    Note: Docker does not provide packages for all architectures. Binary artifacts are built nightly,and you can download them from https://master.dockerproject.org. To install docker on a multi-architecture system,add an[arch=...]clause to the entry. Refer toDebian Multiarch wikifor details.

  6. Run the following command,substituting the entry for your operating system for the placeholder<REPO>.

    $echo"<REPO>"|sudotee/etc/apt/sources.list.d/docker.list
  7. Update theAPTpackage index.

    $sudoapt-getupdate
  8. Verify thatAPTis pulling from the right repository.

    When you run the following command,an entry is returned for each version of Docker that is available for you to install. Each entry should have the URLhttps://apt.dockerproject.org/repo/. The version currently installed is marked with***.The output below is truncated.

    $apt-cachepolicydocker-engine
    
    docker-engine:
    Installed:1.12.2-0~trusty
    Candidate:1.12.2-0~trustyVersiontable:***1.12.2-0~trusty0
    500https://apt.dockerproject.org/repo/ubuntu-trusty/mainamd64Packages100/var/lib/dpkg/status
    1.12.1-0~trusty0
    500https://apt.dockerproject.org/repo/ubuntu-trusty/mainamd64Packages1.12.0-0~trusty0
    500https://apt.dockerproject.org/repo/ubuntu-trusty/mainamd64Packages

    From now on when you runapt-get upgrade,APTpulls from the new repository.

Prerequisites by Ubuntu Version

Ubuntu Xenial 16.04 (LTS),Wily 15.10,Trusty 14.04 (LTS)

For Ubuntu Trusty,Wily,and Xenial,install thelinux-image-extra-*kernel packages,which allows you use theaufsstorage driver.

To install thelinux-image-extra-*packages:

  1. Open a terminal on your Ubuntu host.

  2. Update your package manager.

    $sudoapt-getupdate
  3. Install the recommended packages.

    $sudoapt-getinstalllinux-image-extra-$(uname-r)linux-image-extra-virtual
  4. Go ahead andinstall Docker.

Ubuntu Precise 12.04 (LTS)

For Ubuntu Precise,Docker requires the 3.13 kernel version. If your kernel version is older than 3.13,you must upgrade it. Refer to this table to see which packages are required for your environment:

To upgrade your kernel and install the additional packages,do the following:

    $sudoapt-getupdate
  1. Install both the required and optional packages.

    $sudoapt-getinstalllinux-image-generic-lts-trusty

    Repeat this step for other packages you need to install.

  2. Reboot your host to use the updated kernel.

    $sudoreboot
  3. After your system reboots,go ahead andinstall Docker.

Install the latest versionMake sure you have satisfied all theprerequisites,then follow these steps.

Note: For production systems,it is recommended that youinstall a specific versionso that you do not accidentally update Docker. You should plan upgrades for production systems carefully.

  1. Log into your Ubuntu installation as a user withsudoprivileges.

  2. Update your$sudoapt-getupdate

  3. Install Docker.

    $sudoapt-getinstalldocker-engine
  4. Start thedockerdaemon.

    $sudoservicedockerstart
  5. Verify thatdockeris installed correctly by running thehello-worldimage.

    $sudodockerrunhello-world

    This command downloads a test image and runs it in a container. When the container runs,it prints an informational message and exits.

Install a specific versionTo install a specific version ofdocker-engine:

  1. List all available versions usingapt-cache madison:

    $apt-cachemadisondocker-enginedocker-engine|1.12.3-0~xenial|https://apt.dockerproject.org/repoubuntu-xenial/mainamd64Packages
    docker-engine|1.12.2-0~xenial|https://apt.dockerproject.org/repoubuntu-xenial/mainamd64Packages
    docker-engine|1.12.1-0~xenial|https://apt.dockerproject.org/repoubuntu-xenial/mainamd64Packages
    docker-engine|1.12.0-0~xenial|https://apt.dockerproject.org/repoubuntu-xenial/mainamd64Packages
    docker-engine|1.11.2-0~xenial|https://apt.dockerproject.org/repoubuntu-xenial/mainamd64Packages
    docker-engine|1.11.1-0~xenial|https://apt.dockerproject.org/repoubuntu-xenial/mainamd64Packages
    docker-engine|1.11.0-0~xenial|https://apt.dockerproject.org/repoubuntu-xenial/mainamd64Packages
  2. The second field is the version string. To install exactly1.12.0-0~xenial,append it after the package name in theapt-get installcommand,separated from the package name by an equals sign (=).bash $ sudo apt-get install docker-engine=1.12.0-0~xenial

    If you already have a newer version installed,you will be prompted to downgrade Docker. Otherwise,the specific version will be installed.

  3. Follow steps 4 and 5 ofInstall the latest version.

Install a pre-release versionIf you want to test Docker on Ubuntu,on a non-production system,follow these steps. To install a stable released version of Docker afterward,you will need to revert to the previous configuration.

  1. Edit/etc/apt/sources.list.d/docker.list.

    $sudonano/etc/apt/sources.list.d/docker.list

    Changemaintotestingat the end of the top line. Save and close the file.

  2. Update the package list.

    $sudoapt-getupdate
  3. List the available testing versions.

    $sudoapt-cachemadisondocker-engine
  4. Install a specific version following the same procedure asInstall a specific version.

Optional configurationsThis section contains optional procedures for configuring Ubuntu to work better with Docker.

  • Manage Docker as a non-root user

  • Adjust memory and swap accounting

  • Enable UFW forwarding

  • Configure a DNS server for use by Docker

  • (编辑:安卓应用网)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读