1

This is my set up:

docker-compose.yml:

php:
  container_name: php
  image: pawlik/kinetic-php:5.5
  env_file:
    - .env.defaults

.env.defaults:

STORE_URL_SECURE=https://kinetic.docker.dev/

In the running image I have such simple script:

showvars.sh

echo $STORE_URL_SECURE

Now running:

$ docker-compose run php bash showvars.sh
Starting data
https://kinetic.docker.dev/

looks great, but

$ docker-compose run php echo $STORE_URL_SECURE
Starting data

# empty!

What is the difference? Why in the second example this ENV var is empty?

Greg
  • 5,862
  • 1
  • 25
  • 52

1 Answers1

2

docker-compose run php echo $STORE_URL_SECURE means the shell which executes the docker-compose command also interpret $STORE_URL_SECURE (which is not defined or set in that shell session).
Hence # empty!.

However, this would work:

 docker-compose run php /bin/sh -c 'echo $STORE_URL_SECURE'

(with the strong quotes or simple quotes preventing the shell to interpret $STORE_URL_SECURE right away)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250