Docker技術(shù)之環(huán)境搭建(一)

近日在研究容器相關(guān)的技術(shù),看了vagrantDocker,最終我選擇兩個都研究下,現(xiàn)在我們來看看Docker的環(huán)境搭建。

零. 前期說明

筆者所有的操作系統(tǒng)是DeepIn 15.5,這個由深度科技基于Debian開發(fā)的操作系統(tǒng)。

基于以上的條件,我們安裝Docker也會參考Docker官網(wǎng)上關(guān)于Debian的安裝手冊。

傳送門:Get Docker CE for Debian官方手冊

一、準(zhǔn)備工作

掃盲

English 中文
host 本地主機
image 鏡像
contianer 容器
registry 倉庫
daemon 守護進程
client 客戶端

卸載之前的Docker

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

更新apt軟件索引

sudo apt-get update

二、開始安裝Docker

安裝所依賴的庫文件

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

添加Docker的官方GPG

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

添加source.list添加Docker

sudo add-apt-repository  "deb [arch=amd64] https://download.docker.com/linux/debian wheezy stable“ 

最后更新源

sudo apt-get update

三、安裝Docker-ce

sudo apt-get -y install docker-ce 

root用戶身份管理Docker

創(chuàng)建docker用戶組

sudo groupadd docker

將當(dāng)前用戶添加到docker用戶組

sudo gpasswd -a ${USER} docker  

修改docker.sock的權(quán)限

sudo chmod a+rw /var/run/docker.sock

四、注銷并重新登

到目前為止,dockerDeepin中已經(jīng)安裝完成,現(xiàn)在可以注銷并重新登錄你的組成員權(quán)限。

五、檢測權(quán)限

docker run hello-world

驗證您可以運行docker命令時不需要添加sudo。

該命令會下載一個測試Image并在容器中運行。

如果成功了,可以看到一下信息:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete 
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
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 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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

六、禁止Docker開機自動啟動

安裝chkconfig

sudo apt-get install chkconfig 

禁止開機自動啟動

sudo chkconfig --del docker
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 今天就結(jié)合深度桌面操作系統(tǒng)給大家講講桌面操作系統(tǒng)的架構(gòu)設(shè)計和原理細節(jié),一來向外界講講深度這么多年都做了哪些工作,二...
    ManateeLazyCat閱讀 72,106評論 208 615
  • Docker 是一個開源的應(yīng)用容器引擎,讓開發(fā)者可以打包他們的應(yīng)用以及依賴包到一個可移植的容器中,然后發(fā)布到任何流...
    ProteanBear閱讀 1,461評論 0 3
  • 注意: 該 Docker 版本為了支持 Docker 機,于是不再支持 Boot2Docker 命令行。使用 Do...
    提莫隊長1234閱讀 4,770評論 0 8
  • 在前些天的畢業(yè)聚會上,一個叫阿華的姑娘喝斷片了,沒有撒酒瘋,反而是把她那本來灑脫的性格展現(xiàn)的淋漓盡致。 我有幸與她...
    稱愿姑娘閱讀 300評論 0 0
  • 偶然一次 那曠蕩的操場正中部 在軟軟的草地上躺下 靜靜地 靜靜地 欣賞那一顆顆閃爍的精靈 仿佛聽到自己的心 和大地...
    文德學(xué)習(xí)社閱讀 317評論 0 3

友情鏈接更多精彩內(nèi)容