Dockerfile mkdir permission denied

Dockerfile mkdir permission denied

Docker Filesystems and Docker containers work in a similar manner to filesystems outside a Docker container. You must have the write permissions if you want to create files or directories inside Docker Containers.

First Check if the User you are has the needed permissions. To create a Folder as a non-root user inside the / folder doesn't work because it is owned by the root user and has typically dr-xr-xr-x settings enabled.

Dockerfile mkdir permission denied?

To create directories with non-root users try below command:

RUN mkdir -p /newfolder
RUN chown newuser /newfolder
USER newuser
WORKDIR /newfolder

Provide DockerFile mkdir Permissions to all users

To provide all users read/write/execute permission, Update the directory on the Docker system to have 0777 or drwxrwxrwx permssions.

chmod 0777 /usr/local/docker/foo

πŸ”₯ 1.8K Views
Apr 6, 2022