How to echo environment variables in Docker

My docker-compose.yml is:

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

And in my .env file, I have:

  • Docker image's ID and sha256 are this field related and how generated
  • Running ipython notebook in a Docker Container
  • Can you run Dind as a service on Tutum so that Drone can use it?
  • user: Current not implemented on linux/amd64 with golang using docker scrtach
  • Access S3 in cron job in docker on Elastic Beanstalk
  • Heroku docker deployment
  • # PostgreSQL
    POSTGRES_PASSWORD=mysecretpass
    POSTGRES_USER=postgresuser
    

    How do I test if the environment variables are effectively set?

    I’ve tried tu run on the remote machine:

    docker run sorbetcitron_django echo $POSTGRES_USER
    

    where sorbetcitron_django is my django image, but it outputs nothing.

  • Docker Swarm CD/CI (Jenkins, Docker)
  • Bundling from Github in a Dockerfile
  • Docker: how to send a signal from one running container to another one?
  • Unable to access Asp.Net vNext application hosted in Docker Container in Windows Server 2016 Azure VM [Solved]
  • How to expose host machine aliases to Docker container?
  • Element not found after new sessions is created
  • One Solution collect form web for “How to echo environment variables in Docker”

    I’d use:

    docker-compose run postgres env
    

    If you pass a $POSTGRES_USER to your cli, it’s going to get interpreted by the shell on the host, and if you escape the $, you’ll need to eval the line to get the shell to parse the $ inside the container.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.