0

I'm using Docker inside docker by mount docker.sock into container for Jenkins docker agents. In my Jenkins container, when I execute

docker run -t -d -v /var/data:/var:data image_name

it will not create and mount /var/data folder inside Jenkins container. Instead it create a folder in my host and mounted into agent container.

Does this behavior expected?

Gawain
  • 1,017
  • 8
  • 17
  • 1
    Yes, the left-hand side of a `docker run -v` option is always a physical path on the host, even if `docker run` is being launched from another container. – David Maze Nov 27 '19 at 13:48
  • 1
    Note that if you use the [Jenkins Docker integration](https://jenkins.io/doc/book/pipeline/docker/) and run pipeline commands `image.inside { ... }`, it knows how to mount the current `WORKDIR`, and that Docker named volumes don't have this problem. – David Maze Nov 27 '19 at 13:49
  • Make sense. Thank you David – Gawain Nov 28 '19 at 02:10

0 Answers0