溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何理解data-packed volume container

發(fā)布時(shí)間:2021-11-19 10:38:15 來源:億速云 閱讀:214 作者:柒染 欄目:云計(jì)算

本篇文章為大家展示了data-packed volume container ,內(nèi)容簡明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

volume container 的數(shù)據(jù)歸根到底還是在 host 里,有沒有辦法將數(shù)據(jù)完全放到 volume container 中,同時(shí)又能與其他容器共享呢?

當(dāng)然可以,通常我們稱這種容器為 data-packed volume container。其原理是將數(shù)據(jù)打包到鏡像中,然后通過 docker managed volume 共享。

我們用下面的 Dockerfile 構(gòu)建鏡像:

如何理解data-packed volume container

ADD 將靜態(tài)文件添加到容器目錄 /usr/local/apache2/htdocs。
VOLUME 的作用與 -v 等效,用來創(chuàng)建 docker managed volume,mount point 為 /usr/local/apache2/htdocs,因?yàn)檫@個(gè)目錄就是 ADD 添加的目錄,所以會(huì)將已有數(shù)據(jù)拷貝到 volume 中。 

build 新鏡像 datapacked:

如何理解data-packed volume container

因?yàn)樵?Dockerfile 中已經(jīng)使用了 VOLUME 指令,這里就不需要指定 volume 的 mount point 了。啟動(dòng) httpd 容器并使用 data-packed volume container

容器能夠正確讀取 volume 中的數(shù)據(jù)。data-packed volume container 是自包含的,不依賴 host 提供數(shù)據(jù),具有很強(qiáng)的移植性,非常適合 只使用 靜態(tài)數(shù)據(jù)的場景,比如應(yīng)用的配置信息、web server 的靜態(tài)文件等。

上述內(nèi)容就是data-packed volume container ,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI