Woody1193
Woody1193

Reputation: 7980

Dockerfile - possible command line argument?

I have a value in a Dockerfile called ${APP_NAME}. What is it? If this were bash scripting, I would assume it to be some sort of variable but it hasn't been assigned a value anywhere. Is it a command line argument? If so, how would I pass it in when I wanted to call docker-compose with it?

For reference, the Docker file looks like this:

version: '2'
services:
    nginx:
        container_name: ${APP_NAME}_nginx
        hostname: nginx
        build:
            context: ./containers/nginx
            dockerfile: Dockerfile
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - .:/app
        links:
            - phpfpm
        networks:
            - backend

    phpfpm:
        container_name: ${APP_NAME}_phpfpm
        hostname: phpfpm
        expose:
            - "9000"
        build:
            context: ./containers/php-fpm
            dockerfile: Dockerfile
        working_dir: /app
        volumes:
            - .:/app
        links:
            - mysql
        networks:
            - backend

    mysql:
        container_name: ${APP_NAME}_mysql
        hostname: mysql
        build:
            context: ./containers/mysql
            dockerfile: Dockerfile
        volumes:
            - ./storage/mysql:/var/lib/mysql
            - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d
        environment:
            - MYSQL_DATABASE=${DB_DATABASE}
            - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
        ports:
            - "33061:3306"
        expose:
            - "3306"
        networks:
          - backend

networks:
    backend:
        driver: "bridge"

And actually, I'm probably going to have a lot of questions about docker because I've never really used it before so a reference to Dockerfile syntax would be helpful.

Upvotes: 0

Views: 48

Answers (1)

Lazar Nikolic
Lazar Nikolic

Reputation: 4394

This means that there is probably somewhere in your project .env file which contains variables necessary for docker compose. You can find more about it at the official docker compose docs. It says that you can set default values for environment variables using a .env file, which Compose automatically looks for. Values set in the shell environment override those set in the .env file. Try to find more here: https://docs.docker.com/compose/compose-file/#variable-substitution

Upvotes: 1

Related Questions