high-tech-engineer:Karim Harouat

Karim Harouat
Docker TIPS

Knowledge sharing


The easier way to face permissions issues with files created inside the docker

    When you run a docker image like Ubuntu, the default user is root.
    So that if you run it by sharing a personnal folder from host with option -v, created files won't be readable or writtable for you.
    To fix that, don't think about chown or chmod, there is only one command to run inside your docker container.

  • at runtime:
    • docker run --rm -it -v ${HOME}/folder:/mnt/shared ubuntu:22.04 bash
    • >umask 0

  • at docker creation, add these commands just before your ENTRYPOINT:
    • RUN useradd appuser --create-home
      WORKDIR /home/appuser
      USER appuser
      RUN umask 0