Skip to content

Instantly share code, notes, and snippets.

@suiluj
Created April 5, 2022 09:18
Show Gist options
  • Save suiluj/8a66b909d374d62fb6538eeafa66d994 to your computer and use it in GitHub Desktop.
Save suiluj/8a66b909d374d62fb6538eeafa66d994 to your computer and use it in GitHub Desktop.
Bind mount folder in docker compose without having to change folder or file permissions

Bind mount folder in docker compose without having to change folder or file permissions

  • check user and group of host user: https://kb.iu.edu/d/adwf

    id -u <username>
    id -g <username>
    # (most times both 1000)
    # show all just used id command
    id
  • info for setting user in docker compose: https://stackoverflow.com/a/56904335/5628238

    • set id in service of docker-compose.yml

      services:
        php: # this is my service name
          user: "${UID}:${GID}" # we added this line to get a specific user / group id
          image: php:7.3-fpm-alpine # this is my image
          # and so on
    • set id in .env file next to docker-compose.yml

      UID=1000
      GID=1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment