Skip to content

Boolean environment variable without quotes convert in string  #9842

Description

@GeneralBouLi

Bonjour / Hi
I want to add a environment variable in docker-compose.yml but when I check the variable type in my PHP it convert in string with or without quotes.

I build my containers with the docker-compose you can see at the end of the issue with the command
docker-compose -f docker/php/docker-compose.yml -p base up -d --remove-orphans

Describe the results you received:

In my PHP :

$config['s3fs.settings']['hostname'] = (getenv('S3FS_USE_CUSTOMHOST')) ? getenv('S3FS_CUSTOMHOST') : '';

Don't work because env var is not a boolean

var_dump(getenv('S3FS_USE_CUSTOMHOST')); -> string(5) "FALSE"
var_dump(gettype(getenv('S3FS_USE_CUSTOMHOST'))); -> string(6) "string"

Describe the results you expected:
I need to get boolean value and not string to valid my configuration.

Output of docker version:

Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:38 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:23 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.8
  GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker compose version:

Docker Compose version v2.10.2

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.10.2)
  extension: Manages Docker extensions (Docker Inc., v0.2.9)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.19.0)

Server:
 Containers: 34
  Running: 4
  Paused: 0
  Stopped: 30
 Images: 62
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.104-microsoft-standard
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.773GiB
 Name: docker-desktop
 ID: MHHB:5YKN:UVWJ:CFMZ:ZKQD:DRJA:SA6T:3UHT:5LN5:G2YT:62K6:GTMU
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

docker-compose.yml

version: "3.8"

services:
  db:
    image: all-docker.artifact.cloud.socrate.vsct.fr/mysql:5.7.37
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal
    ports:
      - "3306:3306"
    volumes:
      - ../../docker/mysql/scripts/demo/drupal-next-minimal.sql:/docker-entrypoint-initdb.d/001_drupal-next-minimal.sql
      - ../../docker/mysql/scripts/drupal-db-imported-state.sql:/docker-entrypoint-initdb.d/002_drupal-db-imported-state.sql

  php:
    build:
      context: ../..
      args:
        WWW_DATA_UID: ${UID:-1000}
        WWW_DATA_GID: ${GID:-1000}
      dockerfile: docker/php/Dockerfile
    image: drupal:local
    entrypoint:
      - sh
      - -c
      - docker/php/scripts/install-drupal-files.sh &&
        drupal-docker-php-entrypoint.sh "$$@"
      - _
    command: php-fpm
    environment:
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal
      MYSQL_FQDN: db
      S3FS_ACCESS_KEY: drupaltest
      S3FS_SECRET_KEY: drupaltest
      S3FS_USE_CUSTOMHOST: FALSE
      S3FS_CUSTOMHOST: base-minio-1:9000
      S3FS_ENCRYPTION: 
    volumes:
      - ../../drupal:/opt/drupal

  httpd:
    image: fopp-docker-prod-local.artifact.cloud.socrate.vsct.fr/fopp/httpd:1.0.2
    environment:
      SERVERNAME: localhost
      PHP_FQDN: php
    ports:
      - "8080:80"
      - "80:80"

  minio:
    command: server /data --console-address ":9001"
    environment:
      - MINIO_ROOT_USER=admin
      - MINIO_ROOT_PASSWORD=supersecret
    image: quay.io/minio/minio:latest
    ports:
      - '9000:9000'
      - '9001:9001'
    volumes:
      - /docker/minio:/data
    restart: unless-stopped

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions