Environment variables from docker-compose .env to Dockerfile

1. Declare the variables in .env PHPFPM_IMAGE=php:7.2-fpm USER_ID=1000 2. Pass the variables to Dockerfile using args in docker-compose.yml version: '3' services: app: build: context: . dockerfile: Dockerfile args: PHPFPM_IMAGE: ${PHPFPM_IMAGE} USER_ID: ${USER_ID} 3. Use the keyword ARG to receive the variables in Dockerfile # ARG to use WITH "FROM" ARG PHPFPM_IMAGE FROM $PHPFPM_IMAGE # ARG … Read more