Docker - accessing files inside container from host

前端 未结 3 1159
余生分开走
余生分开走 2021-01-20 00:07

I am new to docker.

I ran a node-10 images and inside the running container I cloned a repository, ran the app which started a server with file watcher. I need to ac

3条回答
  •  盖世英雄少女心
    2021-01-20 00:28

    The concept you are looking for is called volumes. You need to start a container and mount a host directory inside it. For the container, it will be a regular folder, and it will create files in it. For you, it will also be a regular folder. Changes made by either side will be visible to another.

    docker run -v /a/local/dir:/a/dir/in/your/container
    

    Note though that you can run into permission issues that you will need to figure out separately.

提交回复
热议问题