Categories
Uncategorized

The most complete history Docker Environment Installation Guide – make installation simple docker to burst

First, think ❓❔

1. What is the Docker?

    Packaged applications

    Development, testing, operation and maintenance are preferred container technology

    Lightweight

    Expansibility

    Once constructed, many share, run anywhere

2. Install Docker is hard?

  • So easy!
  • After read this article, the reader will certainly be a docker environment

Second, Installing Docker ?? on Windows

1. Install Docker on Windows 10

    system requirement

operating system

RAM

other

Windows 10 64 bit (Home Edition does not work)

4GB or more

Open Hyper-V (Most computers will open by default)

  • Download the installation package

    • https://download.docker.com/win/stable/Docker%20for%20Windows%20Installer.exe
  • Follow the installation wizard next to

  • run

    • Does not start automatically

    • Docker search in the Start menu, open the can

    • Configuration details, refer to this link (https://docs.docker.com/docker-for-windows/#docker-settings-dialog)

  • Test whether the installation is successful

      Run the following command in CMD, showing the version number or showing “Hello from Docker!” , then the installation is successful

    > docker --version
    
    Docker version 19.03.1
    
    > docker run hello-world
    docker : Unable to find image 'hello-world:latest' locally
    ...
    
    latest:
    Pulling from library/hello-world
    ca4f61b1923c:
    Pulling fs layer
    ca4f61b1923c:
    Download complete
    ca4f61b1923c:
    Pull complete
    Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    ...

2. Install Docker in older versions of Windows

    Docker installed on older versions of Windows need to meet the following conditions

operating system

RAM

Other

4GB or more

Turn on Hyper-V (most computers turn on by default)

Windows 7 , 8, 8.1

  • 下载Docker ToolBox安装包
    • https://github.com/docker/toolbox/releases/download/v19.03.1/DockerToolbox-19.03.1.exe

  • installation

    • Detection version

        For Windows 8 or 8.1, open the Task Manager -> Properties -> Enabled Virtualization

        For Windows 7 can use this tool to check if open virtualization https://www.microsoft.com/en-us/download/details.aspx?id=592

    • Double-click the exe installation package, you can follow the installation wizard next

  • Test whether the installation is successful

    • Find Docker QuickStart icon on the desktop, double-click to open Docker

    • If the User Account Control prompt, click Yes

    • There will be a bash terminal

    • Run docker run hello-world, if “Hello from Docker.” Appears, it means running success

     $ docker run hello-world
     Unable to find image 'hello-world:latest' locally
     Pulling repository hello-world
     91c95931e552: Download complete
     a8219747be10: Download complete
     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 Engine CLI client contacted the Docker Engine daemon.
      2. The Docker Engine daemon pulled the "hello-world" image from the Docker Hub.
         (Assuming it was not already locally available.)
      3. The Docker Engine daemon created a new container from that image which runs the
         executable that produces the output you are currently reading.
      4. The Docker Engine daemon streamed that output to the Docker Engine CLI client, which sent it
         to your terminal.
    
     To try something more ambitious, you can run an Ubuntu container with:
      $ docker run -it ubuntu bash
    
     For more examples and ideas, visit:
      https://docs.docker.com/userguide/

3. Install Docker ???? on Linux

1 mounted on Centos

  • linux内核版本依赖
    • kernel version >= 3.8
    • 可以使用如下命令查看
      • uname -a | awk '{split($3, arr, "-"); print arr[1]}'

  • If Docker Docker had been installed, you need to remove the old version

    sudo yum remove docker \
                      docker-client \
                      docker-client-latest \
                      docker-common \
                      docker-latest \
                      docker-latest-logrotate \
                      docker-logrotate \
                      docker-engine

  • Add Docker repository yum source

    # 国内源, 速度更快, 推荐
    sudo yum-config-manager \
        --add-repo \
        https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
    
    
    # 官方源, 服务器在国外, 安装速度慢
    # $ sudo yum-config-manager \
    #     --add-repo \
    #     https://download.docker.com/linux/centos/docker-ce.repo

  • Start the installation Docker Engine

    sudo yum makecache fast
    sudo yum install docker-ce docker-ce-cli containerd.io

  • Open Docker

    sudo systemctl enable docker
    sudo systemctl start docker

  • Verify that the installation was successful

     sudo docker run hello-world

      If the “Hello from Docker.” Appears, it means running success

  • If the command is a docker in each run, do not add sudo in front, you can execute the following command:

    sudo usermod -aG docker $USER

  • If the above installation procedure too cumbersome, you can run the following script to install

      Can not be used in the production system

    curl -fsSL https://get.docker.com -o get-docker.sh
    sudo sh get-docker.sh --mirror Aliyun
    
    sudo systemctl enable docker
    sudo systemctl start docker
    
    sudo groupadd docker
    sudo usermod -aG docker $USER

2. Install on Ubuntu

  • linux kernel version dependent

    • kernel version >= 3.8
    • 可以使用如下命令查看
      • uname -a | awk '{split($3, arr, "-"); print arr[1]}'
  • Operating system dependent, the following versions can be

    Disco 19.04
    Cosmic 18.10
    Bionic 18.04 (LTS)
    Xenial 16.04 (LTS)

  • If Docker Docker had been installed, you need to remove the old version

    sudo apt-get remove docker docker-engine docker.io containerd runc

  • Use Docker repository to install

    # 更新apt包索引
    sudo apt-get update
    
    # 为支持https
    sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common
    
    # 添加Docker GPG秘钥
    # 国内源
    curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
    # 或者国外源
    # curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
    # 添加安装源
    # 推荐国内源
    sudo add-apt-repository \
        "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
        $(lsb_release -cs) \
        stable"
    # 或者国外源
    # sudo add-apt-repository \
    #   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    #   $(lsb_release -cs) \
    #   stable"

  • Installation Docker

    # 更新apt包索引
    sudo apt-get update
    
    # 安装docker
    sudo apt-get install docker-ce docker-ce-cli containerd.io

  • Open Docker

    sudo systemctl enable docker
    sudo systemctl start docker

  • Verify that the installation was successful

     sudo docker run hello-world

      If the “Hello from Docker.” Appears, it means running success

  • If the command is a docker in each run, do not add sudo in front, you can execute the following command:

    sudo usermod -aG docker $USER

Fourth, Install Docker ?? using shell scripts

1 mounted on Ubuntu and Centos

install_docker_.sh

#!/bin/bash
#Author: 柠檬班可优
#Date: 2019-06-06
#install docker in ubuntu and centos


function install_docker_in_ubuntu
{
    sudo  apt-get update -y
    # install some tools
    sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common \
        net-tools \
        wget -y

    # install docker
    curl -fsSL get.docker.com -o get-docker.sh
    sh get-docker.sh

    # start docker service
    sudo groupadd docker &> /dev/null
    sudo gpasswd -a "${USER}" docker
    sudo systemctl start docker

    rm -rf get-docker.sh
}


function install_docker_in_centos
{
    # install some tools
    sudo yum install -y git vim gcc glibc-static telnet bridge-utils

    # install docker
    curl -fsSL get.docker.com -o get-docker.sh
    sh get-docker.sh

    # start docker service
    sudo groupadd docker &> /dev/null
    sudo gpasswd -a "${USER}" docker
    sudo systemctl start docker

    rm -rf get-docker.sh

}


SYSTEM_NAME="$(awk -F= '/^NAME/{print $2}' /etc/os-release)"
if [[ "${SYSTEM_NAME,,}" =~ "ubuntu"  ]] ; then
    echo "Your system is ubuntu."
    echo "Installing Docker in ubuntu..."
    install_docker_in_ubuntu
elif [[ "${SYSTEM_NAME,,}" =~ "centos" ]] ; then
    echo "Your system is centos."
    echo "Installing Docker in centos..."
    install_docker_in_centos
else
    echo "This script can only run in ubuntu and centos system."
    exit 1
fi

2. Run the script

  • bash install_docker_.sh

5. Online practice docker ??

  • katacoda网站:https://www.katacoda.com/

      Every 10 minutes a little exercise

  • Play with Docker网站:https://labs.play-with-docker.com/

      Sign docker account and log in.

      Each can use four hours, after which will be cleared

VI. Summary ??

    This article describes several ways to install docker, I believe there is always a right for you

    Learn popular Docker container technology, installation is the first step docker

Leave a Reply