pass args from docker-compose to dockerfile code example

Example 1: docker compose add arguments

You can specify the arguments directly in your docker-compose file under args:

version: '3'
services:
    rq_dashboad:
        build:
            context: .
            args:
                - RQ_DASHBOARD_REDIS_URL=redis://redis:6379 
        image: IMAGE_NAME_HERE

Example 2: docker-compose build image with args

Usage: build [options] [--build-arg key=val...] [SERVICE...]

Options:
    --build-arg key=val     Set build-time variables for services.
    --compress              Compress the build context using gzip.
    --force-rm              Always remove intermediate containers.
    -m, --memory MEM        Set memory limit for the build container.
    --no-cache              Do not use cache when building the image.
    --no-rm                 Do not remove intermediate containers after a successful build.
    --parallel              Build images in parallel.
    --progress string       Set type of progress output (`auto`, `plain`, `tty`).
    --pull                  Always attempt to pull a newer version of the image.
    -q, --quiet             Don't print anything to `STDOUT`.