𝘋𝘪𝘳𝘬

🏠 Hamburg, Germany
🚃 Daily Commuter
🐧 Linux User
🎮 Part-time Gamer
💻 Hobbyist Coder
🔗 0x7be.de

🇬🇧 / 🇩🇪

  • 1 Post
  • 22 Comments
Joined 1 year ago
cake
Cake day: June 9th, 2023

help-circle











  • This is really dependent on […]

    … basically anything. Yes. You will always find yourself in problems where the best practice isn’t the best solution for.

    In your described use case an option would be having the application inside the container running with 10000:10001 but writing the data into another directory that is configured to use 1000:1001 (or whatever the user is you want to access the data with from your host) and just mount the volume there. This takes a bit more configuration effort than just running the application with 1000:1001 … but still :)


  • Yep! The names are basically just a convenient way for referencing a user or group ID.

    Under normal circumstances you should let the system decide what IDs to use, but in the confined environment of a docker container you can do pretty much what you want.

    If you really, really, really want to create a user and group just set the IDs manually:

    FROM alpine:latest
    COPY myscript.sh /app/myscript.sh
    RUN addgroup -g 10001 mycoolgroup && adduser -D -u 10000 -G mycoolgroup mycooluser
    USER mycooluser:mycoolgroup
    CMD ["sh", "/app/myscript.sh"]
    

    Just make sure to stay at or above 10000 so you won’t accidentally re-use IDs that are already defined on the host.