-2

We use docker containers as our Jenkins build slaves and per VM hosts 10 docker containers.

Question being, does /tmp folder of one container can be accessed by all other containers, will it interfere during the CI build execution ?

There is no special configuration that allows communication among containers but wanted to understand, is there any default settings that allows this feature ?

Goku
  • 482
  • 1
  • 7
  • 22
  • [Sharing volume between Docker containers](https://stackoverflow.com/questions/37000341/sharing-volume-between-docker-containers) ? – Luuk Apr 18 '22 at 06:41
  • @Luuk : Thanks for the link, it's talking about how to share data between containers , but my question is, whether files or directory inside one container is shared across other containers by default, eg. `/tmp` directory ? – Goku Apr 18 '22 at 06:58
  • From the [definition](https://www.docker.com/resources/what-container/): "A container is a standard unit of software that packages up code and **all** its dependencies so the application runs quickly and **reliably** from one computing environment to another. A Docker container image is a lightweight, **standalone**, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings." – Luuk Apr 18 '22 at 07:01
  • Because of 'all','reliably' and 'standalone' nothing outside the container should get involved. – Luuk Apr 18 '22 at 07:02
  • Cool, so until an explicit setting is configured, a container's folders & files are standalone entities and not shared across other containers, is my understanding correct ? – Goku Apr 18 '22 at 07:05
  • That's my understanding of the definition on the website of docker. – Luuk Apr 18 '22 at 07:06

1 Answers1

1

Containers can't access other containers' file systems ever. You can't read or write files or run binaries from another container.

The only exception is if, at startup time, the same external content (either a host directory or a named volume) is mounted into multiple containers. This hides the content that's originally in their respective images in those directories and replaces them with the mounted content; it is not a (reliable) way to publish one image's content to another.

If you use Jenkins's docker.inside() call, the docker run command it generates has a very large number of options that do publish things like the current build directory into the container on the same path. Unless that includes a -v ...:/tmp option, the /tmp directory will be isolated to each container.

David Maze
  • 130,717
  • 29
  • 175
  • 215