Docker: How to access files from another container from a given container?

前端 未结 1 339
走了就别回头了
走了就别回头了 2021-01-29 01:25

Basically I have a main directory and Books Directory (General file structure, there\'s more but these are the important pieces). So when I fire a request from main to booksServ

1条回答
  •  伪装坚强ぢ
    2021-01-29 01:52

    You can create one common datavolume and attached your containers with the datavolume

    Here is the step to create a datavolume,

    Step 1 : docker volume create --name storageOne You can give any name instead of storageOne

    Step 2 : Now you need to attach that volume with the container using docker run -ti --name=myContainer -v storageOne:/storageOne ubuntu command

    Step 3 : Copy or create your required file in that datavolume

    Step 4 : Now Create an another Container using docker run -ti --name=myContainer2 --volumes-from MyContainer ubuntu command

    Step 5 : Restart your myStorage container

    So whatever files are available in myStorage will be shareable between attached container.

    May be this will help you

    0 讨论(0)
提交回复
热议问题