docker 入坑1

来源:https://www.cnblogs.com/mantishell/archive/2019/08/03/11293896.html
-Advertisement-
Play Games

本文是記錄一下學習docker的過程,希望可以幫助到入門的朋友。 系統:ubuntu16.04 docker:18.09 打開官網:https://docs.docker.com/install/linux/docker-ce/ubuntu/ OS requirements To install D ...


本文是記錄一下學習docker的過程,希望可以幫助到入門的朋友。

系統:ubuntu16.04

docker:18.09

打開官網:https://docs.docker.com/install/linux/docker-ce/ubuntu/

OS requirements

To install Docker Engine - Community, you need the 64-bit version of one of these Ubuntu versions:

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

Docker Engine - Community is supported on x86_64 (or amd64), armhf, arm64, s390x (IBM Z), and ppc64le (IBM Power) architectures.

查看我們的系統是否符合最新版docker安裝的要求:

1 mantishell@zkl:~$ uname -a
2 Linux zkl 4.15.0-55-generic #60~16.04.2-Ubuntu SMP Thu Jul 4 09:03:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
3 mantishell@zkl:~$ lsb_release -a
4 No LSB modules are available.
5 Distributor ID:    Ubuntu
6 Description:    Ubuntu 16.04.6 LTS
7 Release:    16.04
8 Codename:    xenial

符合最後一條:Xenial 16.04 (LTS)

如果不符合,怎麼辦呢?不要灰心,可以安裝歷史版本。官網也有說明。

Install Docker Engine - Community

You can install Docker Engine - Community 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

Before you install Docker Engine - Community 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:

    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:

    $ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
    
  3. Add Docker’s official GPG key:

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

    Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

    $ sudo apt-key fingerprint 0EBFCD88
        
    pub   rsa4096 2017-02-22 [SCEA]
          9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid           [ unknown] Docker Release (CE deb) <[email protected]>
    sub   rsa4096 2017-02-22 [S]
    
  4. Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

    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 need to change $(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are using Linux Mint Tessa, you could use bionic. Docker does not offer any guarantees on untested and unsupported Ubuntu distributions.

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

Install Docker Engine - Community

  1. Update the apt package index.

    $ sudo apt-get update
    
  2. Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:

    $ sudo apt-get install docker-ce docker-ce-cli containerd.io
    

    Got multiple Docker repositories?

    If you have multiple Docker repositories enabled, installing or updating without specifying a version in the apt-get install or apt-get update command always installs the highest possible version, which may not be appropriate for your stability needs.

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

    a. List the versions available in your repo:

    $ apt-cache madison docker-ce
    
      docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 18.06.1~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 18.06.0~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      ...
    

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

    $ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
    
  4. Verify that Docker Engine - Community 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 Engine - Community 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.

Upgrade Docker Engine - Community

To upgrade Docker Engine - Community, 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 Engine - Community, you can download the .deb file for your release and install it manually. You need to download a new file each time you want to upgrade Docker.

  1. Go to https://download.docker.com/linux/ubuntu/dists/, choose your Ubuntu version, browse to pool/stable/, choose amd64, armhf, arm64, ppc64el, or s390x, and download the .deb file for the Docker Engine - Community version you want to install.

    Note: To install a nightly package, change the word stable in the URL to nightly. Learn about nightly and test channels.

  2. Install Docker Engine - Community, 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 Engine - Community 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 Engine - Community 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.

Upgrade Docker Engine - Community

To upgrade Docker Engine - Community, 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 Engine - Community 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 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 Engine - Community 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 https://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 them the ability to run containers which can be used to obtain root privileges on the Docker host. Refer to Docker Daemon Attack Surface for more information.

Docker Engine - Community 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.

Uninstall Docker Engine - Community

  1. Uninstall the Docker Engine - Community 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.

上面是官方給的步驟,相信大家按照步驟一步步進行,也能搭建起來。這裡呢我記錄一下,我的操作步驟:

  1. Update the apt package index:
    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:
    $ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
    

     

  3. Add docker`s offical GPG key:
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

     

  4. set up the repository
    $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get update
    

     

  5. Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:
    $ sudo apt-get install docker docker-compose
    

     

  6. To install a specific version of Docker Engine - Community, list the available versions in the repo, then select and install:
    1. List the versions available in your repo:
      $ apt-cache madison docker-ce
      

       

    2. Install a specific version using the version string from the second column, for example, 5:18.09.1~3-0~ubuntu-xenial
      $ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io $ sudo apt-get install docker-ce=5:18.09.0~3-0~ubuntu-xenial docker-ce-cli=5:18.09.0~3-0~ubuntu-xenial containerd.io
      

       

  7. Verify that Docker Engine - Community is installed correctly by running the hello-world image.
    $ sudo docker run hello-world
    

     

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 系統為應用程式分配所需的記憶體以及其他資源,記憶體和資源的物理分離叫做進程。 進程是以線程為單位競爭CPU,那麼什麼是線程呢? 線程可看成一個可執行的指令單元,他使用進程中的數據,包含若幹條指令,進程與線程的對應是一對多 這五個線程會輪流競爭CPU資源。 CPU按 時間片 輪流執行各個線程 操作系統提供 ...
  • 一、Wifi無法連接 ip addr 顯示:unmanaged, plugin missing 先連有線網yum install -y NetworkManager-wifi systemctl restart NetworkManager.service 二、筆記本合上後休眠 yum instal ...
  • 環境:CentOS7 一.本地源的yum源的搭建 (一)添加新的yum源配置文件iso.repo(名字可以自己命名,但是尾碼必須是repo結尾) 註意:目錄 /etc/yum.repos.d 下的 .repo 文件將會被yum工具讀取 建議:只保留一個 .repo的文件。 [root@uplooki ...
  • CentOS6.4系統上安裝KVM虛擬機 備註:以下操作說明是經過實驗驗證後總結出來的筆錄,有需要的朋友可以進行參考,以下是基於VMware12.5.2虛擬機版本上安裝的實驗環境。 一、安裝KVM 1. kvm需要有 CPU 的支持(Intel VT 或 AMD SVM)。輸入命令:egrep '^ ...
  • 最近公司內部一個需求:必須 Linux建個 ntp server ,並且 Windows可以net time \\ip 訪問。 摸索之後,開工: ########### ntp server ip a # 本機IP 192.168.52.5 yum install -y ntp # 安裝服務 ntp ...
  • 購買 Hostwinds VPS 首先確認不要使用任何代理,網路是什麼 IP 就是什麼 IP ,不然可能需要人工審核,導致 Hostwinds VPS 購買顯示 "Pending" 狀態, 不能即時創建服務激活。 1、通過 Hostwinds 優惠鏈接進入Hostwinds 首頁,選擇 “VPS” ...
  • Linux常用目錄——存放 /bin 所有用戶可以使用的可執行文件 /sbin 新管理員使用的執行文件 /boot Linux內核映像文件和與引導載入有關的文件 /dev 設備文件 /etc 系統配置文件 /mnt 掛載點,常用於掛載文件系統 /lib 共用庫文件 /proc 基於記憶體的文件系統,用 ...
  • CRT遠程連接centos7,連接超時 問題原因: 宿主機(win10)和虛擬機(centos7)不在同一個網段 在宿主機無法ping通虛擬機, 首先在cmd視窗ipconfig查看一下vmnet的ip地址 然後在centos使用命令ifconfig查看ip地址 現在宿主機和虛擬機在同一個網段,所以 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...