<p>One could use <a href="https://docs.docker.com/engine/admin/volumes/volumes/#use-a-read-only-volume" rel="nofollow noreferrer">read-only volumes</a>. </p>

<blockquote>
<pre><code>docker run -d \
  -it \
  --name=nginxtest \
  -v nginx-vol:/usr/share/nginx/html:ro \
  nginx:latest
</code></pre>
</blockquote>

<p>If one would like to use the same volume in multiple containers then one could specify the following when running each container:</p>

<pre><code>-v vol:/usr/share/nginx/html:ro
</code></pre>

<p>Note: one could use <code>ro</code> to ensure that the volume is read-only to prevent that multiple containers will write at the same time to the same volume and prevent issues.</p>

CC BY-SA 3.0
2017-10-06T10:27:42.663Z
Yes, but in this case, I have a doubt that VM will be started because I do there: vagrant up; vagrant suspend.
user54
CC BY-SA 3.0
2017-10-06T10:29:02.013Z
Why would you like to run the containers in a VM and not on the host machine itself?
030
CC BY-SA 3.0
2017-10-06T10:31:12.593Z
Containers will be run on host and inside container will be run VM.
user54
CC BY-SA 3.0
2017-10-06T10:37:46.173Z
why do you run a VM in a container?
030
CC BY-SA 3.0
2017-10-06T11:30:40.277Z
Because that VM will be FreeBSD VM. I can not run FreeBSD container under Linux and I can not setup FreeBSD as host OS to use FreeBSD containers as long as Docker is an experimental thing in FreeBSD and Kubernetes is not supported under FreeBSD.
user54
CC BY-SA 3.0
2017-10-06T11:33:38.183Z
That is valuable information that should be added to the question in my opinion
030
CC BY-SA 3.0
2017-10-06T11:38:22.187Z
The question was updated.
user54
CC BY-SA 3.0
2017-10-06T10:26:04.907Z
2017-10-06T10:28:27.333Z
2017-10-06T10:28:27.333Z
030
<p>I have Docker image which contains config files of VirtualBox and I want to use this image for running multiple containers in parallel.</p>

<p>Config files of VM are being stored on host OS, however, I am afraid of issues with config data of VMs which may occur because of parallel accessing by multiple containers. 
All containers will be started by Jenkins automatically.</p>

<p>Therefore, could you please tell what is the best way to share data between containers to avoid data corruption because of parallel usage?</p>

<p>Please note: I can not run FreeBSD container under Linux and I can not setup FreeBSD as host OS to use FreeBSD containers as long as Docker is an experimental thing in FreeBSD and Kubernetes is not supported under FreeBSD.</p>

CC BY-SA 3.0
2017-10-06T11:35:03.653Z
Please update the question.
030
CC BY-SA 3.0
2017-10-06T12:00:56.997Z
Why not running the VM from host ? VirtualBox allow to share a disk between VMs solving your problem, your main problem is adding a process segregation between your virtualbox processes , in brief, you're trying to work against docker isolation for no reason, remove docker from the equation ...
Tensibai
CC BY-SA 3.0
2017-10-06T12:02:18.493Z
Side note: I'm downvoting the question because there's no explanation of why you're using docker in this case.
Tensibai
CC BY-SA 3.0
2017-10-06T12:04:06.750Z
Because there is Kubernetes cluster which will manage and redistribute containers in parallel. All tests/instructions will be started from Jenkins.
user54
CC BY-SA 3.0
2017-10-06T12:29:27.783Z
Virtualbox, k8s? huh? I agree with @Tensibai
030
CC BY-SA 3.0
2017-10-06T13:02:38.087Z
Are your config files being modified by the containers? What kind of issues are their with accessing the config files in parallel?
Preston Martin
CC BY-SA 3.0
2017-10-06T14:43:27.090Z
@user54 Well back to root question: Why on earth running those test on top of a kubernetes cluster at all ? Sometimes you have to take a step back and see something is just a footgun and not a proper solution. Use a normal host with a jenkins agent and start multiples virtualbox on it. what is the target goal ? just testing under freebsd ? creating a vbox image of freebsd for redistribution ? Why freebsd and not switching OS if it brings you that much problems ?
Tensibai
<docker>
The best way to share volume with config data between multiple Docker containers
user54
# The best way to share volume with config data between multiple Docker containers

(Asked by: username_0 on 2017-10-05)

I have Docker image which contains config files of VirtualBox and I want to use this image for running multiple containers in parallel.

Config files of VM are being stored on host OS, however, I am afraid of issues with config data of VMs which may occur because of parallel accessing by multiple containers.
All containers will be started by Jenkins automatically.

Therefore, could you please tell what is the best way to share data between containers to avoid data corruption because of parallel usage?

Please note: I can not run FreeBSD container under Linux and I can not setup FreeBSD as host OS to use FreeBSD containers as long as Docker is an experimental thing in FreeBSD and Kubernetes is not supported under FreeBSD.

**Tags:** docker

> **Comments:**
> **username_1**: Please update the question.  
> **username_2**: Why not running the VM from host ? VirtualBox allow to share a disk between VMs solving your problem, your main problem is adding a process segregation between your virtualbox processes , in brief, you're trying to work against docker isolation for no reason, remove docker from the equation ...  
> **username_2**: Side note: I'm downvoting the question because there's no explanation of why you're using docker in this case.  
> **username_0**: Because there is Kubernetes cluster which will manage and redistribute containers in parallel. All tests/instructions will be started from Jenkins.  
> **username_1**: Virtualbox, k8s? huh? I agree with @username_2  
> **username_3**: Are your config files being modified by the containers? What kind of issues are their with accessing the config files in parallel?  
> **username_2**: @username_0 Well back to root question: Why on earth running those test on top of a kubernetes cluster at all ? Sometimes you have to take a step back and see something is just a footgun and not a proper solution. Use a normal host with a jenkins agent and start multiples virtualbox on it. what is the target goal ? just testing under freebsd ? creating a vbox image of freebsd for redistribution ? Why freebsd and not switching OS if it brings you that much problems ?  

---

## 1 answers

### Answer by username_1 on 2017-10-06. Score: 1 | Accepted answer

One could use read-only volumes. 

docker run -d \
  -it \
  --name=nginxtest \
  -v nginx-vol:/usr/share/nginx/html:ro \
  nginx:latest


If one would like to use the same volume in multiple containers then one could specify the following when running each container:
-v vol:/usr/share/nginx/html:ro

Note: one could use ro to ensure that the volume is read-only to prevent that multiple containers will write at the same time to the same volume and prevent issues.

> **Comments:**
> **username_0**: Yes, but in this case, I have a doubt that VM will be started because I do there: vagrant up; vagrant suspend.  
> **username_1**: Why would you like to run the containers in a VM and not on the host machine itself?  
> **username_0**: Containers will be run on host and inside container will be run VM.  
> **username_1**: why do you run a VM in a container?  
> **username_0**: Because that VM will be FreeBSD VM. I can not run FreeBSD container under Linux and I can not setup FreeBSD as host OS to use FreeBSD containers as long as Docker is an experimental thing in FreeBSD and Kubernetes is not supported under FreeBSD.  
> **username_1**: That is valuable information that should be added to the question in my opinion  
> **username_0**: The question was updated.  

---

