Home > Blockchain >  Environment variable is ignored on Docker compose
Environment variable is ignored on Docker compose

Time:11-26

In my docker-compose I have a couple of variables which I want to pass to my Spring Boot Kotlin module. Part of my docker-compose.yml is

version: '3.9'
services:
  tomcat:
    image: backend:latest
    ports:
      - "8080:8080"
      - "5005:5005"
    container_name: tomcat
    environment:
      my-app_env_one: something
      spring_datasource_username: user

my-app_env_one is not available in my module but the spring_datasource_username still is. What am I doing wrong? I'm new to Docker, so sorry if I got something completely wrong. So the image is running right now but I have no idea why I don't get the variables.

CodePudding user response:

Environment variables enter image description here

Change - to _:

my-app_env_one -> my_app_env_one

Also you can enable debug=true in your spring boot or inspect your container docker inspect app_name to get more details.

  • Related