Scenario I want to use Docker in Docker as per this guide
The key point is that you'll need to bind mount the Docker socket from host machine into the Docker socket inside the container in order to use Docker from inside the container.
Issue The Docker socket on the host machine is always bind mounted into Docker container under root:root. When I execute the container as a non-root user, executing Docker commands gives permission denied.
Question How to bind mount a file from host into Docker container with specific user:group and permission?
You need to run the appropriate chown and chmod commands to change the permissions of the directory. This assumes you have the runuser command available. You can accomplish pretty much the same thing using sudo instead.
Bind mounts will mount a file or directory on to your container from your host machine, which you can then reference via its absolute path. To use bind mounts, the file or directory does not need to exist on your Docker host already. If it doesn't exist, it will be created on demand.
I think you can workaround that:
set the group permission on the file to ID
not exists on the host
, and give the group full access:
chown :999 /path/to/file
chmod 775 /path/to/file
chmod g+s /path/to/file
then on your Dockerfile add the group
and assign the user
to it:
RUN addgroup --gid 999 GROUPNAME
RUN adduser --disabled-password --gecos "" --force-badname --ingroup 999 USERNAME
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With