apocas / dockerode

Docker + Node = Dockerode (Node.js module for Docker's Remote API)
Apache License 2.0
4.39k stars 465 forks source link

Mounting container on directory #737

Closed NicolaLovo closed 1 year ago

NicolaLovo commented 1 year ago

With docker run is possible to mount a container on a specific local directory. For example lets say that I have the directory "test" and I want to mount the container's working dir to this folder, I would say via docker cli:

docker run -v $(pwd):/usr/src/app -d ubuntu

So that if I chech the contents of usr/src/app I would found the exact same contents of my folder "test".

Is it possible to do this with dockerode?

NicolaLovo commented 1 year ago

Found a solution, when you create your container just use this option:

HostConfig: {
      Binds: [`${process.cwd()}/src/test:/usr/src/app`],
},