How to update permissions on base image for Docker? (mambaorg/micromamba)

171 views Asked by At

Here's my Dockerfile:

# v2023.8.21
# =================================
# Micromamba
# =================================

FROM mambaorg/micromamba:1.4.9

ARG ENV_NAME

SHELL ["bash"]

WORKDIR /tmp/

# Data
RUN mkdir -p /volumes/
RUN mkdir -p /volumes/input
RUN mkdir -p /volumes/output
RUN mkdir -p /volumes/database

# Retrieve VEBA repository
RUN mkdir -p veba/
COPY --chown=$MAMBA_USER:$MAMBA_USER ./install/ veba/install/
COPY --chown=$MAMBA_USER:$MAMBA_USER ./src/ veba/src/
COPY --chown=$MAMBA_USER:$MAMBA_USER ./VERSION veba/VERSION
COPY --chown=$MAMBA_USER:$MAMBA_USER ./LICENSE veba/LICENSE


RUN micromamba install -y -n base -f veba/install/environments/${ENV_NAME}.yml && \
    micromamba clean -a -y -f

However, I'm unable to create the /volumes/ directories because of permission issues.

How can I update the permissions so I can edit the root directory?

1

There are 1 answers

2
larsks On BEST ANSWER

If you mean that lines like this are failing:

RUN mkdir -p /volumes/

Then you can switch the user running the commands with the USER directive, and the switch back to the original user when you're done:

# switch to root to create /volumes hierarchy
USER root

RUN mkdir -p /volumes
RUN mkdir -p /volumes/input
RUN mkdir -p /volumes/output
RUN mkdir -p /volumes/database

# switch back to mambauser
USER mambauser