Binding volume with 'withFileSystemBind' -> Permission Denied #4462
Replies: 5 comments 10 replies
-
Hey @naturzukunft, thanks for recreating here. As written in the SO comment, let's work backward from a working Docker CLI call. Your Testcontainers code represents this Docker CLI command, which already fails:
What is the working Docker command? Once we know it, we can transform it into corresponding Testcontainers code. |
Beta Was this translation helpful? Give feedback.
-
if i create a docker volume on my local machine with: Is there a way to create a volume using testcontainers? |
Beta Was this translation helpful? Give feedback.
-
I did some test together with @naturzukunft and we found out following: Docker-Managed volumes:(Basically forcing docker to create a volume on the fly) Docker commandline: I can see that the mount on /mnt/spring is owned by the user spring as defined in the Dockerfile. The container runs fine.
Mount folder directlyDocker commandline: The container will fail on runtime as it cannot write the data inside
RemarksFor both file listings I overwrote the entrypoint with So as it looks like (correct my if wrong), testcontainers is using the second way to directly mount the folders using Edit for the remarks: Using Docker Desktop on Windows with Docker using the WSL2 backend. |
Beta Was this translation helpful? Give feedback.
-
using a relative path for GenericContainer also ends in a directory that is owned by root.
The folder is created in the project directory: .../target
test was executed in springToolSuite, which was started by a not root user. |
Beta Was this translation helpful? Give feedback.
-
I have a slight feeling we are working around unnecessary problems as long as we don't understand your original use case. Why do you need files from the host in the container in the first place? Or the other way around, do you need files from the container on the host? The easiest way to get files into the container is using |
Beta Was this translation helpful? Give feedback.
-
This is the discussion to find a solution for the problem: https://stackoverflow.com/questions/68653002/binding-volume-with-withfilesystembind-permission-denied
Beta Was this translation helpful? Give feedback.
All reactions