Home > other >  Container Docker mounted directory to the host machine
Container Docker mounted directory to the host machine

Time:09-22

Everybody is good, I just use the Docker, my goal is to mount the directory within the container to the host machine, rather than hosting directory mounted to the container,, about which I know you can use the -v parameter, but for the former, I don't know should how to do it, search for a moment, it is said that can use the Volume Volume, but I don't know how to use it, please help me. Thank you.

CodePudding user response:

When Dockerfile defined Volume, then the docker run docker run - v & lt; Host_dir & gt; : & lt; Volume_dir & gt;
For example,
1) VOLUME ["/var/lib/mysql "]
2) the docker run - d - v/mysql/data:/var/lib/mysql

CodePudding user response:

Run the docker run -- help command to see documentation
- v - volume=[] Bind mount a volume

-v parameter is mounted, you said container run after any change made to it can't be saved, are read-only, so you like mount has no meaning, you want to view the running state of container? Can mount a directory such as/etc/system/etc directory in to the container, so should be ok,

CodePudding user response:

Lz, to share, to support you

CodePudding user response:

Hello, the building Lord, is you solved this problem? Has also had the same problem now I don't know how to solve,

CodePudding user response:

Direct access to the docker inspect - f {{. GraphDriver. Data. MergedDir}} ${containerid} can point to the directory, this is the file system, run time container
For example:
CD $(docker inspect - f {{. GraphDriver. Data. MergedDir}} test01)
If you want to put the container of a directory under the map to a custom directory, the host machine can be used to mount -- bind, of course, ln -s,
  • Related