數(shù)據(jù)共享

容器與host共享數(shù)據(jù)

容器之間共享數(shù)據(jù)

volume container

data-packed volume container

volume container的數(shù)據(jù)歸根到底還是在host里,有木有辦法將數(shù)據(jù)完全放到volume container中,同事又能與其他容器共享呢?
當(dāng)然可以,通常我們稱這種容器為data-packed volume container.其原理是將數(shù)據(jù)打包到鏡像中,然后通過docker managed volume共享
我們用下面的Dockfile構(gòu)建鏡像:

From busybox:latest
ADD htdocs /usr/local/apache2/htdocs
VOLUME /usr/local/apache2/htdocs

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

?著作權(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)容

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