Repository navigation
Description
Apache NetBeans version
Apache NetBeans 31
What happened
Hi!
I find very useful the panel Services > Docker, where you can easily see and manage Images and Containers.
before explaining the problem, a little premise.
Today's security best practices suggest to use a .env file to store env-variables that is better not to include into a artifact (war/jar),
and that normally are managed by Kubernetes via Secrets: a classical example are DB variables (DB_URL, DB_USER, DB_PWD)
And here is the problem.
if you just use terminal/console to build and run a Docker project, you can tell Docker to use this .env file.
for example:
Dockerfile:
# BUILD #############################################
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY target/MyProj-0.0.1.jar app.jar
COPY .env .env
# RUN #############################################
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]command to build:
docker build --build-arg SKIP_TESTS=true -t myproject .command to run (using .env variables) :
docker run -p 8080:8080 --env-file .env myprojectso my step on Netbeans simply are these 2:
- from Dockerfile, right click, Build... , fill all required fields, and everything is ok, creating new IMAGE under Docker images tree interface.
- from this new image, right click, Run...
and that's the point: when Run start, the .env variables are ignored
I dont know in Run Dialog, how to add extra param "--env-file .env" ; I've tried in Command input box, but nothing happen, or maybe I write something wrong into this filed.
Can anybody help me to understand if I've made mistakes, or the .env feature is missing in the current Docker Service?
thanks!
Language / Project Type / NetBeans Component
Java Maven Web application project
How to reproduce
with dockers running, simply create a java web project that simply print a System.getenv("MSG"):
- create a .env file with this content:
MSG=johnDoe123
- create a Dockerfile in same root of pom.xml
# BUILD #############################################
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY target/HelloDocker-0.0.1.jar app.jar
COPY .env .env
# RUN #############################################
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]-
from Dockerfile, right click, BUILD.... and create the image
-
in Services > Docker > Local Docker > Images > HelloDocker, right click, RUN ... and complete.
and you can see that values is not the one stored in .env file
Did this work correctly in an earlier version?
No / Don't know
Operating System
windows 11
JDK
26, but build with 17 version
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
it occurs always, because I think is a missing feature
Are you willing to submit a pull request?
No
Activity
matthiasblaesing commentedon Sep 15, 2026
@millo74 I had a look at your request and created #9618. It would be great if you could have a look at it and test. The nightly built is available from https://github.com/apache/netbeans/suites/94504581322/artifacts/10369653335.
millo74 commentedon Sep 15, 2026
Hello Matthias, first of all I've tried again the HelloDocker project with your fixed build and it works perfectly!!
to test the company project (where I notice the bug for the very first time) I need some days or maybe more, because in the meantime they changed network system in my office and all the connection that concern my project are temporaly offline....
I just can use a virtual system to bypass this problem, but is not yet configured to use docker....
please have patience and wait for my next further tests
THANKS to have fixed the bug in so short time!!
matthiasblaesing commentedon Sep 15, 2026
@millo74 thanks for testing. Would you mind also having a look at #9619 (nightly build: https://github.com/apache/netbeans/suites/94505691659/artifacts/10370032666)? Both PRs belong into the Docker area and I'm not a heavy user of the netbeans feature myself, so a real test would be nice.
Docker: Enhance run dialog to define an environment for the container…