How to echo environment variables in Docker
<p>My docker-compose.yml is:</p>

<pre><code>version: '2'

volumes:
  postgres_data: {}
  postgres_backup: {}

services:
  postgres:
    build: ./compose/postgres
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - postgres_backup:/backups
    env_file: .env

  django:
    build:
      context: .
      dockerfile: ./compose/django/Dockerfile
    user: django
    depends_on:
      - postgres
      - redis
    command: /gunicorn.sh
    env_file: .env

  nginx:
    build: ./compose/nginx
    depends_on:
      - django

    ports:
      - "0.0.0.0:80:80"


  redis:
    image: redis:latest
    restart: always
</code></pre>

<p>And in my .env file, I have:</p>

<pre><code># PostgreSQL
POSTGRES_PASSWORD=mysecretpass
POSTGRES_USER=postgresuser
</code></pre>

<p>How do I test if the environment variables are effectively set?</p>

<p>I've tried tu run on the remote machine:</p>

<pre><code>docker run sorbetcitron_django echo $POSTGRES_USER
</code></pre>

<p>where <strong>sorbetcitron_django</strong> is my django image, but it outputs nothing.</p>