docker-compose local variable declare and use
https://docs.docker.com/compose/environment-variables/#the-env-file

One could set a variable in an .env file:

TAG=1.2.3


and call it in a docker-compose file

docker-compose.yml

version: "3"
services:
  web:
    image: nginx:${TAG}
    ports:
    - 80:80


docker-compose up

returns:

Pulling web (nginx:1.2.3)...
ERROR: manifest for nginx:1.2.3 not found


No need to run docker-compose to check the config

According to the documentation one could run:

docker-compose config


to verify the docker-compose config

networks: {}
services:
  web:
    image: nginx:1.2.3
    ports:
    - 80:80/tcp
version: '3.0'
volumes: {}