0

As we know, we can mount a host folder using docker run -v or docker create -v.

But how can we mount a host folder when container already created?

Doerthous
  • 323
  • 1
  • 11
  • Searching the internet for "docker mount volume in running container" turns up several posts, e.g. https://jpetazzo.github.io/2015/01/13/docker-mount-dynamic-volumes/ . Not sure whether that approach still works, though. – Frank Schmitt Aug 20 '22 at 08:54
  • 2
    Containers are meant to be ephemeral, so the 'right' way to do it is to stop your container and run it again with the correct mounts. https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#create-ephemeral-containers – Hans Kilian Aug 20 '22 at 09:08
  • So, I have to reconfiguration the environment(install lots of tools)? I try to create a image from container which is too big, 3+GB, but the size of parent image is just 300+MB – Doerthous Aug 20 '22 at 09:44
  • If you follow the best practices guide and make your containers ephemeral, you'd install the tools in an image, so you can stop and start your containers with minimal work. Installing the tools in an image or in the container should give the same container size. – Hans Kilian Aug 20 '22 at 10:53

0 Answers0