Skip to content

Docker Service not able to read system variables from .env file while launch RUN from a Docker image #9559

Closed

Description

@millo74

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 myproject

so my step on Netbeans simply are these 2:

  1. from Dockerfile, right click, Build... , fill all required fields, and everything is ok, creating new IMAGE under Docker images tree interface.
  2. 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"):

  1. create a .env file with this content:

MSG=johnDoe123

  1. 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"]
  1. from Dockerfile, right click, BUILD.... and create the image

  2. in Services > Docker > Local Docker > Images > HelloDocker, right click, RUN ... and complete.

  3. from Browser: http://localhost:8080/

and you can see that values is not the one stored in .env file

HelloDocker.zip

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

  1. added
    kind:bug
    needs:triage
    on Aug 12, 2026
  2. added
    kind:feature
    and removed
    kind:bug
    needs:triage
    on Sep 14, 2026
  3. matthiasblaesing commented on Sep 15, 2026

    @matthiasblaesing
    Contributor

    @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.

  4. millo74 commented on Sep 15, 2026

    @millo74
    Author

    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!!

  5. matthiasblaesing commented on Sep 15, 2026

    @matthiasblaesing
    Contributor

    @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.

  6. added a commit that references this issue on Sep 27, 2026
    492fc26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Dockerkind:feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions