zoukankan      html  css  js  c++  java
  • debian 9 安装docker

    【官方】

    debian 7 -- wheezy

    debian 8 -- jessie

    debian 9 -- stretch

    Uninstall old versions

    安装过的话,先移除旧的软件

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

    SET UP THE REPOSITORY

    1. 更新仓库信息:

      $ sudo apt-get update
    2. 安装软件包:

             3. 添加官方GPG key:    

    $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

             通过搜索后8位验证密钥:

    $ 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. 设置库

    $ sudo add-apt-repository 
       "deb [arch=amd64] https://download.docker.com/linux/debian 
       $(lsb_release -cs) 
       stable"

    INSTALL DOCKER CE

    Note: This procedure works for Debian on x86_64 / amd64, Debian ARM, or Raspbian.

    1. 更新软件仓库:

      $ sudo apt-get update
    2. 安装最新版Docker CE:

      $ sudo apt-get install docker-ce

      我在这一步提示,E: Unable to locate package docer-ce

      搜了下资料执行了如下后,可以正常安装,具体原因不详,赶着下班能安装成功就万事大吉  - . -  :

      echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list.d/docker.list
      sudo apt-get update
      sudo apt-cache policy docker-ce

      提示如下:

      docker-ce:
        Installed: (none)
        Candidate: 18.03.0~ce-0~debian
        Version table:
           18.03.0~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.12.1~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.12.0~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.09.1~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.09.0~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.06.2~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.06.1~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.06.0~ce-0~debian 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.03.2~ce-0~debian-stretch 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.03.1~ce-0~debian-stretch 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
           17.03.0~ce-0~debian-stretch 500
              500 https://download.docker.com/linux/debian stretch/stable amd64 Packages
      docer-ce

      接着安装docker-ce:

      sudo apt-get install docker-ce
    3. 在生产环境你需要安装一个特定版本的Docker CE而非总是最新的. 这个输出截断可以列出可用的版本:

      $ apt-cache madison docker-ce
      
      docker-ce | 17.12.0~ce-0~debian | https://download.docker.com/linux/debian jessie/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_STRING> 

      The Docker daemon starts automatically.

    4. 通过运行 hello-world 镜像来验证Docker CE安装成功.

      x86_64:

      $ sudo docker run hello-world 

      armhf:

      $ 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. The docker group is created but no users are added to it. 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. For Raspbian, you can optionally install Docker Compose for Raspbian.

    非root权限使用docker

    sudo groupadd docker //创建docker组
    
    sudo gpasswd -a ${USER} docker //将当前用户加入docker组
    
    sudo systemctl restart docker //重新启动docker服务
    
    当前用户退出系统重新登陆
    
    docker ps //运行docker命令

    UPGRADE 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

    如果你不能使用Docker仓库来安装Docker CE, 你可以下载相应发行版的 .deb文件并手动安装。 你每次想要更新Docker的时候都需要下载一个新的文件.

    1. Go to https://download.docker.com/linux/debian/dists/, choose your Debian version, browse to pool/stable/, choose either amd64 or armhf, and download the .deb file for the Docker CE 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.

      $ 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. The docker group is created but no users are added to it. 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. For Raspbian, you can optionally install Docker Compose for Raspbian.

    UPGRADE DOCKER CE

    To upgrade Docker, 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 edge and testing versions of Docker CE into development environments quickly and non-interactively. The source code for the scripts is in the docker-installrepository. 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 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.
    • The script does not provide options to specify which version of Docker to install, and installs the latest version that is released in the “edge” channel.
    • 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 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 to log out and back in for this to take effect!
    
    WARNING: Adding a user to the "docker" group grants 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 can’t 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.

    Install Docker Compose for Raspbian

    You can install Docker Compose using pip:

    $ sudo pip install docker-compose
    

    Hypriot provides a static binary of docker-compose for Raspbian. It may not always be up to date, but if space is at a premium, you may find it useful. To use it, first follow Hypriot’s instructions for setting up the repository, then run the following command:

    sudo apt-get install docker-compose
    

    Uninstall 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
  • 相关阅读:
    php中模拟多继承如何实现
    js进阶 12-4 jquery键盘事件如何使用
    php课程 3-12 带默认参数的函数怎么写
    android_线
    Cocos2d-x 文本渲染
    一张地图告诉你,只JavaScript不够!
    python 导入库问题
    Cocos2d-X字体
    R语言做文本挖掘 Part5情感分析
    Java存储区域——JVM札记&lt;一个&gt;
  • 原文地址:https://www.cnblogs.com/kuboy/p/8625811.html
Copyright © 2011-2022 走看看