-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment variables not properly passed in 8.5.16 #77
Comments
This is related to docker-library/openjdk#135. I will make a PR to update |
Without rebuilding the tomcat image I used your test with just one minor tweak and it worked: version: '2'
services:
8516-tomcat:
image: tomcat:8.5.16
container_name: 8516-tomcat
volumes:
- ./8516webapps:/usr/local/tomcat/webapps/
environment:
- test.variable=This is set on the container as an ENV var
command:
- 'bash'
- 'catalina.sh'
- 'run' 8516-tomcat | 2017-07-27 22:23:50.035 INFO 1 --- [ost-startStop-1] hu.jlaci.Application : Spring: Test Variable is: This is set on the container as an ENV var
8516-tomcat | 2017-07-27 22:23:50.036 INFO 1 --- [ost-startStop-1] hu.jlaci.Application : Java : Test Variable is: This is set on the container as an ENV var And it still is just java running in the container (bash gets out of the way): $ docker top 8516-tomcat
UID PID PPID C STIME TTY TIME CMD
root 28014 27996 2 15:18 ? 00:00:14 /docker-java-home/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start |
Thank you for your help, both with the pull request and the workaround! It works and its rather painless. |
The change to bash seems to break the locale. When using |
I believe this fix is removing |
@tomasdev, the tomcat images only install the jre and so have never come with |
True, but |
This Dockerfile was written assuming that we need to install the jdk to build tomcat native; if you make your own Dockerfile to change to a base that already has the jdk installed, then you'll need to adjust any packages that are added or removed in the RUN lines. |
The upstream entrypoint is `sh` and so loses dotted environment variables, lets prevent that from happening by just skipping it as the `tomcat` images isn't reliant on its functionality (docker-library/docs#2338). Fixes docker-library#302 which is a recurrence of docker-library#77
The upstream entrypoint is `sh` and so loses dotted environment variables, lets prevent that from happening by just skipping it as the `tomcat` images isn't reliant on its functionality (docker-library/docs#2338). Fixes docker-library#302 which is a recurrence of docker-library#77
The upstream entrypoint is `sh` and so loses dotted environment variables, lets prevent that from happening by just skipping it as the `tomcat` images are not reliant on its functionality. See docker-library/docs#2338 and adoptium/containers#392 for info about what it provides. Fixes docker-library#302 which is a recurrence of docker-library#77
Background
We run Spring Boot Web applications in Dockerized Tomcats, configured using Spring Boot's externalized configuration (https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html).
When upgrading from 8.5.14 to 8.5.16 we noticed our configurations was no longer working. After some investigations we came to conclude that this is a problem with the docker image, not the SpringBoot itself. To demonstrate and reproduce the issues I created a small demo application setup, which can be found here:
https://github.com/jlaci/SpringBootTomcatTestEnv
Setup
The demo application tries to resolve the
property, which is provided in to two places, the application.properties file (which is the default) and overridden in the container by an environmental variable. To illustrate this, here is the application.properties and the docker-compose file for both versions:
application.properties
docker-compose.yml
The application prints out both the Spring Boot resolved value and the raw environmental variable visible by the JVM.
Expected outcome
The application then resolves the property and the expected outcome is for the environmental variable to override the default one. This was the case in 8.5.14 but not in 8.5.16:
Logs from 8.5.14
Logs from 8.5.16
Eliminated causes
Docker / Docker compose
A manually created container also displays the issue:
When listing the environment variables for the containers, apparently each container has the required variable:
8.5.14
8.5.16
Tomcat itself
When run natively on the host os with the following command:
both version works fine
Logs from 8.5.14
Logs from 8.5.16
Spring Boot
The System.getenv(); call doesn't work either and natively the application is fine.
Workaround
If we use the KEY_NAME=value syntax instead of the key.name=value 8.5.16 works fine:
Docker-Compose
Logs from 8.5.16 with different syntax
Conclusion
The support for environmental variables with uncapitalized keys seperated by dots has been lost between 8.5.14 and 8.5.16.
The text was updated successfully, but these errors were encountered: