question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you set environment variables?

See original GitHub issue

I tried something like:

CreateContainerResponse containerResponse = dockerClient.createContainerCmd("testApp")
            .withEnv("DISPLAY=$DISPLAY")
            .exec();

but this doesn’t seem to work. The $DISPLAY mentioned is supposed to be the value of the environment variable on the Ubuntu system where the docker daemon is running. I verified that it’s properly defined.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
orzehcommented, Oct 13, 2017

@Shanky2304 In https://docs.docker.com/engine/reference/run/#env-environment-variables :

If the operator names an environment variable without specifying a value, then the current value of the named variable is propagated into the container’s environment

In that case AFAIK the value is read from client environment.

Back to your example, you can read DISPLAY env variable and pass it to Java code:

String dispayVarValue = System.getEnv(...);
CreateContainerResponse containerResponse = dockerClient.createContainerCmd("testApp")
            .withEnv("DISPLAY=" + dispayVarValue)
            .exec();

It that code runs on docker daemon you will get what you want.

0reactions
Shanky2304commented, Oct 13, 2017

@orzeh I’m sorry, I don’t understand. What do you mean I don’t have access? What should have I done differently?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Set Environment Variables - Twilio
Setting environment variables in Windows using the GUI is hidden behind several layers of settings dialogs. To open the respective interface you ...
Read more >
How do I set an environment variable? - Schrödinger
In the User variables section, select the environment variable you want to modify. · Click Edit to open the Edit User Variable dialog...
Read more >
How do I set or change the PATH system variable? - Java
Windows 10 and Windows 8 · In Search, search for and then select: System (Control Panel) · Click the Advanced system settings link....
Read more >
How to set the path and environment variables in Windows
In the Environment Variables window (pictured below), highlight the Path variable in the System variables section and click the Edit button. Add ...
Read more >
Set Environment Variable in Windows {How-To} - phoenixNAP
Set Environment Variable in Windows via GUI · 1. Press Windows + R to open the Windows Run prompt. · 2. Type in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found