ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

手把手ubuntu18.04安装docker步骤

2022-07-01 07:00:25  阅读:313  来源: 互联网

标签:手把手 sudo apt ce install ubuntu docker ubuntu18.04


    01.业务背景

    使用ubuntu18.04来安装docker

   

    02.安装什么

    安装docker-engine和安装docker-compose


    03.官网地址

    docker的官网:https://www.docker.com

    ubuntu18.04安装docker的参考地址:

    https://docs.docker.com/engine/install/ubuntu/

   
    参考文章:Install Docker Engine on Ubuntu

    无须安装docker-desktop


    04.安装docker

    步骤01.清理旧版

    如果以前安装过docker,可以将旧版本进行卸载(one line).

    卸载01:

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

    卸载02:

    sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin

    卸载03:

    sudo rm -rf /var/lib/docker

    sudo rm -rf /var/lib/containerd


    步骤02.创建仓库

    如果你是第一次安装docker,那么需要安装docker仓库.

    Update the apt package index and install packages to allow apt to use a repository over HTTPS:

    执行2.1: sudo apt-get update

    执行2.2: (one line)

    sudo apt-get install ca-certificates curl gnupg lsb-release

   

    Add Docker’s official GPG key:

    执行2.3: sudo mkdir -p /etc/apt/keyrings

    执行2.4:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

   

    Use the following command to set up the repository:

    执行2.5: (one line)

    echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

   

    需要确认不同的操作系统版本号,配置的数据根本不同.

    使用ubuntu18.04,因此配置是bionic.

    sudo gedit /etc/apt/sources.list.d/docker.list

    deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu bionic stable


    步骤03.下载引擎

    Install Docker Engine.

    Update the apt package index, and install the latest version of Docker Engine, containerd, and Docker Compose, or go to the next step to install a specific version:

    执行3.1: sudo apt-get update

    执行3.2: -- 安装了三个组件.

    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

      

    To install a specific version of Docker Engine,list the available versions in the repo, then select and install:

    a. List the versions available in your repo:

    执行3.3:

    apt-cache madison docker-ce

   

    

   

    b. Install a specific version using the version string from the second column.for example, 5:20.10.16~3-0~ubuntu-jammy.

    执行3.4的命令参考:

    sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin

    参考案例:

    docker-ce | 5:20.10.17~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages

    docker-ce | 5:20.10.16~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages

    执行3.4:

    sudo apt-get install docker-ce=5:20.10.17~3-0~ubuntu-bionic docker-ce-cli=5:20.10.17~3-0~ubuntu-bionic containerd.io docker-compose-plugin


    步骤04.执行镜像

    Verify that Docker Engine is installed correctly by running the hello-world image.

    执行4.1:sudo docker run hello-world


    This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.Docker Engine 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.

    步骤05.启动镜像

    01.如何启动docker

    执行命令: sudo systemctl start docker

    02.查看docker进程

    执行命令: ps -ef | grep docker

    03.执行镜像

    执行命令: sudo docker run hello-world

   

   

   
    05.安装docker-compose

    步骤01.查看python

    pip3是Python中的标准库管理器,它允许你安装和管理不属于 Python标准库的其它软件包.因为在ubuntu中可能安装python2或者python3.可能存在不同的pip工具.

    本文主要使用python3来做验证.

    验证:pip3 -V

    安装: sudo apt install python3-pip

    更新:pip3 install --upgrade pip


    执行验证和更新命令.

    列出已安装的包: pip3 list


    步骤02.安裝docker-compose

    执行安装: pip install docker-compose

标签:手把手,sudo,apt,ce,install,ubuntu,docker,ubuntu18.04
来源: https://www.cnblogs.com/zhtzyh2012/p/16433249.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有