Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variables for client OS/arch and client user UID/GID #11821

Closed
wants to merge 1 commit into from

Commits on May 15, 2024

  1. Add environment variables for client OS/arch and client user UID/GID

    When using Docker Compose for development setup, you often need to tweak the configuration to vary on Linux, macOS, and Windows. And some services you would like to run with the same UID/GID as your current client user.
    
    To help with that, we introduce four new environment variables while parsing the configuration files:
    
    - `COMPOSE_CLIENT_OS`: set to Go's `runtime.GOOS`
    - `COMPOSE_CLIENT_ARCH`: set to Go's `runtime.GOARCH`
    - `COMPOSE_CLIENT_UID`: set to the current users UID
    - `COMPOSE_CLIENT_GUID`: set to the current users GID
    
    This way, we can now have a Docker Compose setup like this:
    
    compose.yaml:
    ```yaml
    services:
      php:
        image: php
        volumes:
          - .:/code
        user: ${COMPOSE_CLIENT_UID}:${COMPOSE_CLIENT_GID}
      web:
        image: apache
        extends:
          file: compose.${COMPOSE_CLIENT_OS}.yaml
          service: web
    ```
    
    compose.linux.yaml:
    ```yaml
    services:
      web:
        environment:
          VIRTUAL_HOST: mysite.local
    ```
    
    compose.darwin.yaml:
    ```yaml
    services:
      web:
        environment:
          VIRTUAL_HOST: mysite.docker
    ```
    
    Closes docker#11820.
    
    Signed-off-by: Arne Jørgensen <arne@arnested.dk>
    arnested committed May 15, 2024
    Configuration menu
    Copy the full SHA
    91002f5 View commit details
    Browse the repository at this point in the history