Docker - accessing files inside container from host

前端 未结 3 1200
余生分开走
余生分开走 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:34

    It depends on what you want to do with the files.

    There is the docker cp command that you can use to copy files to/from a container.

    However, it sounds to me like you are using docker for development, so you should mount a volume instead, that is, you mount a directory on the host as a volume in docker, so anything written to that directory will show up in the container, and vice versa.

    For instance if you have the code base that you develop against in C:\src on your windows machine, then you run docker like docker run -v c:\src:/app where /app is the location that node is looking in. However, for Windows there are a few things to consider since Docker is not native in Windows, so have a look at the documentation first.

提交回复
热议问题