-1

I look around but don't find a runnable solution.

What I want: I want to create a Windows Batch file to build my docker-compose envirenment and pass througth some parameters, like Username and Password. But the parameters don't comes in docker-composer.

My minimal script:

@echo off
set arg1=%1
set arg2=%2

IF "%arg1%" == "" GOTO wrongPara
IF "%arg2%" == "" GOTO wrongPara
set ADMIN_USER="%arg1%"
set ADMIN_PASSWORD="%arg2%"
docker-compose build --no-cache
docker-compose up --build --force-recreate
GOTO end

:wrongPara
echo All Parameters are needed. $1 = Username, $2 = Password

:end
echo Finished

my Docker-Compose File is:

 grafana:
    image: grafana/grafana
    hostname: grafana
    container_name: grafana
    ports:
      - "3000:3000"
    links:
      - prometheus
    depends_on:
      - prometheus
    restart: always
    environment:
      - GF_SECURITY_ADMIN_USER=${ADMIN_USER}
      - GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD}

I run the Batch-Script for example:

install.bat admin password

So I want to set grafana user is "admin" and password is "password"

but both are empty. What do I wrong?

Burner
  • 981
  • 19
  • 41
  • Does this answer your question? [How to use environment variables in docker-compose?](https://stackoverflow.com/questions/29377853/how-to-use-environment-variables-in-docker-compose) – Reda E. Sep 29 '22 at 16:07
  • The code above works very well. Look in my own answer. I readn the post from you, but there is not explain how it works with batch files. – Burner Sep 30 '22 at 05:58

1 Answers1

0

the mistake is on another place.

docker compose convert --format yaml

shows the right values

Burner
  • 981
  • 19
  • 41