I build my own Docker image based on tomcat:9-jdk11-openjdk-buster. 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
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
If I use the "tomcat:9-jdk11-openjdk-buster" as image the "my-app_env_one" variable is available. If I use my own docker image it's not there but the "spring_datasource_username" still is.
What am i doing wrong? Do i have to introduce the env variables in my dockerfile somewhere?
Dockerfile:
FROM tomcat:9-jdk11-openjdk-buster
COPY container/startContainer.sh /config/startContainer.sh
RUN ["chmod", " x", "/config/startContainer.sh"]
# in entrypoint script original entrypoint is called
ENTRYPOINT ["/config/startContainer.sh"]
part of my startContainer.sh:
#!/bin/sh
echo "-----Start tomcat-----"
catalina.sh run
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.
Thanks for any help
CodePudding user response:
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.