Q:

docker-compose, can't print environment variable in docker container

I want to print environment variable defined in docker-compose file.
Here is my docker-compose-1.yml:
version: '3.6'

services:
  busybox:
    image: busybox
    command: 'echo $DEBUG'
    environment:
      - DEBUG='123456'

And, try to print the DEBUG environment variable in docker container:
☁  environment-variables-in-compose [master] ⚡  docker-compose -f docker-compose-1.yml up
WARNING: The DEBUG variable is not set. Defaulting to a blank string.
Creating network "environmentvariablesincompose_default" with the default driver
Creating environmentvariablesincompose_busybox_1 ... done
Attaching to environmentvariablesincompose_busybox_1
busybox_1  |
environmentvariablesincompose_busybox_1 exited with code 0

As you can see, got WARNING: The DEBUG variable is not set. Defaulting to a blank string. 
Am I wrong?
update 1:
docker-compose-1.yml:
version: '3.6'

services:
  busybox:
    image: busybox
    command: 'echo $$DEBUG'
    environment:
      DEBUG: 123456

I change command using double $ sign, but the result is still not what I want.
☁  environment-variables-in-compose [master] ⚡  docker-compose -f docker-compose-1.yml up
Creating network "environmentvariablesincompose_default" with the default driver
Creating environmentvariablesincompose_busybox_1 ... done
Attaching to environmentvariablesincompose_busybox_1
busybox_1  | $DEBUG
environmentvariablesincompose_busybox_1 exited with code 0

As you can see, the environment variable is printed as $DEBUG, not expected value 123456

A:

Compose will expand variables from the environment where you are running compose. To expand the variable inside your container, escape the $ using $$:
command: '/bin/sh -c "echo $$DEBUG"'

For more details, see: https://docs.docker.com/compose/compose-file/#variable-substitution
Edit: I've also added a shell inside the container to expand the variable.

