2-docker 安裝

2-docker 安裝

Ubuntu 安裝

由于 apt 源使用 HTTPS 以確保軟件下載過程中不被篡改。因此,我們首先需要添加使用 HTTPS 傳輸的軟件包以及 CA 證書。

$ sudo apt-get update$ sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg-agent \software-properties-common

為了確認所下載軟件包的合法性,需要添加軟件源的 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 -

然后,我們需要向 source.list 中添加 Docker 軟件源

$ 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"

以上命令會添加穩定版本的 Docker CE APT 鏡像源,如果需要最新或者測試版本的 Docker CE 請將 stable 改為 edge 或者 test。從 Docker 17.06 開始,edge test 版本的 APT 鏡像源也會包含穩定版本的 Docker。

安裝 Docker CE

$ sudo apt-get update$ sudo apt-get install docker-ce

Centos 安裝

  1. 安裝依賴
$ sudo yum install -y yum-utils \device-mapper-persistent-data \lvm2
  1. 添加穩定版本的倉庫
$ sudo yum-config-manager \--add-repo \https://download.docker.com/linux/centos/docker-ce.repo
  1. 安裝
sudo yum install docker-ce

會提示你 Is this OK? 輸入 y 然后回車。之后會再次提示確認指紋信息,看一下是否是 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35(不區分大小寫),如果是,再次輸入 y 然后回車,一般都沒問題。

使用腳本自動安裝

在測試或開發環境中 Docker 官方為了簡化安裝流程,提供了一套便捷的安裝腳本,Ubuntu 系統上可以使用這套腳本安裝:

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

如果 get-docker.sh 不能下載,點擊下載。
執行這個命令后,腳本就會自動的將一切準備工作做好,并且把 Docker CE 的 Edge 版本安裝在系統中。

啟動 Docker CE

$ sudo systemctl enable docker
$ sudo systemctl start docker

Ubuntu 14.04 請使用以下命令啟動:

$ sudo service docker start

建立 docker 用戶組

默認情況下,docker 命令會使用 Unix socket 與 Docker 引擎通訊。而只有 root 用戶和 docker 組的用戶才可以訪問 Docker 引擎的 Unix socket。出于安全考慮,一般 Linux 系統上不會直接使用 root 用戶。因此,更好地做法是將需要使用 docker 的用戶加入 docker 用戶組。

建立 docker 組:

$ sudo groupadd docker

將當前用戶加入 docker 組:

$ sudo usermod -aG docker $USER

退出當前終端并重新登錄,進行如下測試。

測試 Docker 是否安裝正確

$ docker run hello-worldUnable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latestHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://cloud.docker.com/For more examples and ideas, visit:https://docs.docker.com/engine/userguide/

若能正常輸出以上信息,則說明安裝成功。

鏡像加速

鑒于國內網絡問題,后續拉取 Docker 鏡像十分緩慢,強烈建議安裝 Docker 之后配置 國內鏡像加速

Ubuntu 16.04+、Debian 8+、CentOS 7

對于使用 systemd 的系統,請在 /etc/docker/daemon.json 中寫入如下內容(如果文件不存在請新建該文件)

{"registry-mirrors": ["https://registry.docker-cn.com"]
}

注意,一定要保證該文件符合 json 規范,否則 Docker 將不能啟動。

配置Docker DNS

第一種方式:

/etc/docker/daemon.json 配置全部容器的 DNS,文件中增加以下內容來設置。

  "dns" : ["114.114.114.114","8.8.8.8"]

然后重啟 docker 服務,并驗證:

sudo service docker restart
vincent@scijet_server_1:~$ docker exec -it gitlab-runner bash
root@5d4b8905c983:/# cat /etc/resolv.conf 
nameserver 114.114.114.114
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.1
root@5d4b8905c983:/# exit

第二種方式:

所有 Docker 容器的 DNS 配置通過 /etc/resolv.conf 文件立刻得到更新。

# 在容器中使用 mount 命令可以看到掛載信息:$ mount
/dev/disk/by-uuid/1fec...ebdf on /etc/hostname type ext4 ...
/dev/disk/by-uuid/1fec...ebdf on /etc/hosts type ext4 ...
tmpfs on /etc/resolv.conf type tmpfs ...

有關daemon.json文件

以下是完整的daemon.json文件可配置的參數表,我們在配置的過程中,只需要設置我們需要的參數即可,不必全部寫出來。詳細參考,官方文檔。

{"api-cors-header": "","authorization-plugins": [],"bip": "","bridge": "","cgroup-parent": "","cluster-store": "","cluster-store-opts": {},"cluster-advertise": "","debug": true,"default-gateway": "","default-gateway-v6": "","default-runtime": "runc","default-ulimits": {},"disable-legacy-registry": false,"dns": [],"dns-opts": [],"dns-search": [],"exec-opts": [],"exec-root": "","fixed-cidr": "","fixed-cidr-v6": "","graph": "","group": "","hosts": [],"icc": false,"insecure-registries": [],"ip": "0.0.0.0","iptables": false,"ipv6": false,"ip-forward": false,"ip-masq": false,"labels": [],"live-restore": true,"log-driver": "","log-level": "","log-opts": {},"max-concurrent-downloads": 3,"max-concurrent-uploads": 5,"mtu": 0,"oom-score-adjust": -500,"pidfile": "","raw-logs": false,"registry-mirrors": [],"runtimes": {"runc": {"path": "runc"},"custom": {"path": "/usr/local/bin/my-runc-replacement","runtimeArgs": ["--debug"]}},"selinux-enabled": false,"storage-driver": "","storage-opts": [],"swarm-default-advertise-addr": "","tls": true,"tlscacert": "","tlscert": "","tlskey": "","tlsverify": true,"userland-proxy": false,"userns-remap": ""
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/536112.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/536112.shtml
英文地址,請注明出處:http://en.pswp.cn/news/536112.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

U-Net++粗略解釋

Paper:UNet: A Nested U-Net Architecture for Medical Image Segmentation u-net網絡的基本拓撲結構 目前最先進的圖像分割模型是各種個同樣的 encoder-decoder架構,他們具有一個關鍵的相似性:skip connections,它可以將編碼器…

Spring中的組合模式

組合模式是一種對象設計模式,它允許你將對象組合成樹形結構以表示“部分-整體”的層次結構,使得客戶端以統一的方式處理單個對象和對象的組合。在Spring框架中,組合模式被廣泛應用,讓我們深入分析一下。 在Spring中,組…

Docker+Nginx部署Angular

DockerNginx部署Angular 在部署Angular生產環境之前,需要電腦已經安裝docker。 添加Dockerfile 在已經完成的Angular項目的項目根目錄下添加Dockerfile文件。 Dockerfile文件內容: FROM nginx:1.11-1.11-alpine COPY index.html /usr/share/nginx/ht…

U-net網絡詳解

U-net網絡 簡單說一下網絡圖中各項所代表的內容: 藍/白色框表示feature map(特征圖) 藍色箭頭表示3x3卷積,主要用于特征提取 灰色箭頭表示skip-connection(跳躍連接,通常用于殘差網絡中),在這里是用于用于特征融合&…

Angular Web App部署Ubuntu Nginx

Angular Web App部署Ubuntu Nginx 當我們想發布Angular Web App的時候,我們想在開發的時候部署測試,那么這篇文章使用Nginx來部署我們的Angular 系統環境 lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.4 LTS Rele…

遺傳算法-01背包

遺傳算法 算法思想 遺傳算法(Genetic Algorithm, GA)是模擬達爾文生物進化論的自然選擇和遺傳學機理的生物進化過程的計算模型,是一種通過模擬自然進化過程搜索最優解的方法。 其主要特點是直接對結構對象進行操作,不存在求導和函…

Angular Web App部署Linux Nginx Https

Angular Web App部署Linux Nginx Https 提示:這篇文章是基于內網的 互聯網就開始將 WEB 服務從 HTTP 遷移到 HTTPS,而現在為了更快的推進 HTTPS 的普及,Chrome 將從 2018 年 7 月起標記所有的 HTTP 網站為不安全鏈接。 HTTPS 會逐漸成為 WEB 服務的標配,最最重要的是,它能…

SOLO算法簡讀

論文鏈接:https://arxiv.org/abs/1912.04488 代碼鏈接:https://github.com/WXinlong/SOLO 摘要 提出一種新的實例分割方法。與語義分割等其他密集預測任務相比,實例分割的難度要大得多。為了預測每個實例的掩碼,主流方法要么遵…

Rxjs的flatMap使用

Rxjs的flatMap使用 flatMap是Rxjs比較繞的一個概念,這里我們只是講解如何使用。在Rxjs 4.0版本時叫flatMap,在Rxjs 5.0時被更名為margeMap,現在flatMap作為margeMap的別名使用,這是考慮向下兼容。 官方flatMap的定義: Projects each sourc…

關于Loss的簡單總結

Dice Loss 參考:https://blog.csdn.net/l7H9JA4/article/details/108162188 Dice系數: 是一種集合相似度度量函數,通常用于計算兩個樣本的相似度,取值范圍為[0,1]。 s2∣X∩Y∣∣X∣∣Y∣s \frac{2|X ∩ Y|}{|X||Y|} s∣X∣∣Y…

Angular_PWA使用+Demo

Angular_PWA使用+Demo 什么是PWA PWA(Progressive Web App)利用TLS,webapp manifests和service workers使應用程序能夠安裝并離線使用。 換句話說,PWA就像手機上的原生應用程序,但它是使用諸如HTML5,JavaScript和CSS3之類的網絡技術構建的。 如果構建正確,PWA與原生應…

SOLOv2論文簡讀

論文:SOLOv2: Dynamic, Faster and Stronger 代碼:https://github.com/WXinlong/SOLO 摘要 主要提出了作者在SOLOv2中實現的優秀的實例分割方法,旨在創建一個簡單、直接、快速的實例分割框架: 通過提出動態學習對象分割器的mas…

Angular6_PWA

Angular6_PWA Angular正式發布了V6.0,我們已經可以利用對應的@angular/cli V6.0來直接開發PWA應用了。 第一步:安裝@angular/cli V6.0 如果你機器上有老版本,請先卸載。 打開你的終端,執行: npm install -g @angular/cli 或 cnpm install -g @angular/cli 安裝成功…

Ubuntu18.04 關于使用vnc的踩坑

由于種種原因,手上多了一臺可使用的桌面版Ubuntu,正好用來測試代碼,方便調試。因為只能遠程,所以需要配置遠程連接。因此就打算使用vnc進行遠程連接,誰料一路坎坷,特此記錄。 安裝 設置桌面共享 需要注意…

App_Shell模型

App_Shell模型 App Shell 架構是構建 Progressive Web App 的一種方式,這種應用能可靠且即時地加載到您的用戶屏幕上,與本機應用相似。 App shell是支持用戶界面所需的最小的 HTML、CSS 和 JavaScript,如果離線緩存,可確保在用戶重復訪問時提供即時、可靠的良好性能。這意…

Angular6_服務端渲染SSR

Angular6_服務端渲染 在使用服務端渲染之前,需要安裝最新版本的Angular。 npm install -g @angular/cli 或 cnpm install -g @angular/cli github項目 創建項目 ng new PWCat --routing 為項目添加universalng g universal --client-project=PWCat 或

Jenkins自定義主題教程

Jenkins自定義主題 由于Jenkins自帶的樣式比較丑陋,所以有很多第三方的樣式庫,這里針對jenkins-material-theme樣式庫做一個安裝教程。 下載樣式庫 下載連接 Select your color 選擇一個你喜歡的主題顏色。Choose your company logo 上傳你自定義的…

IndexedDB_Web 離線數據庫

IndexedDB_Web 離線數據庫 本文會從頭剖析一下 IndexedDB 在前端里面的應用的發展。 indexedDB 目前在前端慢慢得到普及和應用。它正朝著前端離線數據庫技術的步伐前進。以前一開始是 manifest、localStorage、cookie 再到 webSQL,現在 indexedDB 逐漸被各大瀏覽器認…

Angular 單元測試講解

Angular_單元測試 測試分類 按開發階段劃分按是否運行劃分按是否查看源代碼劃分其他ATDD,TDD,BDD,DDD ATDDTDDBDDDDDAngular單元測試 Karma的介紹jasmine介紹單元測試的好處使用jasmine和karma創建一個Angular項目Karma配置Test.ts文件測試體驗測試Form測試服務service常用斷言…

基于 Docker 的微服務架構

基于 Docker 的微服務架構-分布式企業級實踐前言Microservice 和 Docker服務發現模式客戶端發現模式Netflix-Eureka 服務端發現模式ConsulEtcdZookeeper 服務注冊自注冊模式 Self-registration pattern第三方注冊模式 Third party registration pattern小結一 服務間的 IPC 機制…