How to mount a directory in the docker container to the host?

后端 未结 5 2136
广开言路
广开言路 2020-12-31 16:05

It\'s quite easy to mount a host directory in the docker container.

But I need the other way around.

I use a docker container as a development environment fo

5条回答
  •  孤城傲影
    2020-12-31 16:41

    I had a similar need of exposing the files from container to the host. There is an open issue on this as of today. One of the work-arounds mentioned, using binds, is pretty neat; it works when the container is up and running:

    container_root=$(docker inspect --format {{.State.Pid}} "$container_name")/root
    sudo bindfs --map=root/"$USER" "$container_root/$app_folder" "$host_folder"
    

    PS: I am not sure this is good for production, but it should work in development scenarios!

提交回复
热议问题