1. 程式人生 > >基於Docker 搭建自己的webrtc 伺服器:(一)在ubuntu14.04搭建Docker 環境

基於Docker 搭建自己的webrtc 伺服器:(一)在ubuntu14.04搭建Docker 環境

一.環境準備

​​​​​​1.安裝額外linux-image-extra-*  軟體包

linux-image-extra-* 包用於允許Docker使用aufs儲存驅動程式。AUFS是一種聯合檔案系統。它使用同一個Linux host上的多個目錄,逐個堆疊起來,對外呈現出一個統一的檔案系統。AUFS使用該特性,實現了Docker映象的分層。

執行如下命令

sudo apt-get update
sudo apt-get install \
    linux-image-extra-$(uname -r) \
    linux-image-extra-virtual

2.更新apt

包索引

sudo apt-get update

3.安裝包以允許apt通過HTTPS使用儲存庫

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

這一步主要安裝一些工具軟體例如 https、curl等。

4.新增Docker的官方GPG金鑰

通過curl 新增GPG祕鑰,執行如下命令

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

成功會返回OK

9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88通過搜尋指紋的最後8個字元,在終端驗證您現在擁有帶指紋的金鑰 ,輸入如下命令:

sudo apt-key fingerprint 0EBFCD88

終端會打印出如下資訊:

/etc/apt/trusted.gpg
--------------------
pub   1024D/437D05B5 2004-09-12
      Key fingerprint = 6302 39CC 130E 1A7F D81A  27B1 4097 6EAF 437D 05B5
uid                  Ubuntu Archive Automatic Signing Key <
[email protected]
> sub 2048g/79164387 2004-09-12 pub 1024D/FBB75451 2004-12-30 Key fingerprint = C598 6B4F 1257 FFA8 6632 CBA7 4618 1433 FBB7 5451 uid Ubuntu CD Image Automatic Signing Key <[email protected]> pub 4096R/C0B21F32 2012-05-11 Key fingerprint = 790B C727 7767 219C 42C8 6F93 3B4F E6AC C0B2 1F32 uid Ubuntu Archive Automatic Signing Key (2012) <[email protected]> pub 4096R/EFE21092 2012-05-11 Key fingerprint = 8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092 uid Ubuntu CD Image Automatic Signing Key (2012) <[email protected]> pub 1024D/3E5C1192 2010-09-20 Key fingerprint = C474 15DF F48C 0964 5B78 6094 1612 6D3A 3E5C 1192 uid Ubuntu Extras Archive Automatic Signing Key <[email protected]> pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid Docker Release (CE deb) <[email protected]> sub 4096R/F273FCD8 2017-02-22

5.設定源

使用以下命令設定穩定儲存庫。即使您還想從邊緣測試儲存庫安裝構建,您始終需要穩定的儲存 庫。要新增邊緣或 測試儲存庫,請在下面的命令中的單詞後新增單詞或(或兩者)。edgeteststable

注意:下面的lsb_release -cs子命令返回您的Ubuntu發行版的名稱,例如xenial。有時,在像Linux Mint這樣的發行版中,您可能需要更改$(lsb_release -cs) 為父Ubuntu發行版。例如,如果您正在使用Linux Mint Rafaela,則可以使用trusty

          ubuntu不同的版本,源是不一樣的,我的是14.04tls 64位,所以設定如下:

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

 二.開始安裝Docker

1.更新apt包索引

sudo apt-get update

2.安裝最新版本的Docker CE,或轉到下一步安裝特定版本:

sudo apt-get install docker-ce
  1. 有多個Docker儲存庫?

    如果您啟用了多個Docker儲存庫,則在未指定apt-get install或 apt-get update命令中的版本的情況下安裝或更新始終會安裝儘可能高的版本,這可能不適合您的穩定性需求。

3.安裝特定的版本

要安裝特定版本的Docker CE,請列出repo中的可用版本,然後選擇並安裝:

一個。列出您的倉庫中可用的版本:

apt-cache madison docker-ce

docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

按其完全限定的包名稱安裝特定版本,例如,包名稱(docker-ce)“=”版本字串(第2列)docker-ce=18.03.0~ce-0~ubuntu

sudo apt-get install docker-ce=<VERSION>

Docker守護程式自動啟動。

4.通過執行hello-world 映像驗證是否正確安裝了Docker CE 。

sudo docker run hello-world

如果安裝成功會列印如下資訊:

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 client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/