windows icon indicating copy to clipboard operation
windows copied to clipboard

Passing environment variables from Docker container to Windows

Open geekopslc opened this issue 2 years ago • 8 comments

Operating system

ubuntu 22.04

Description

I need to pass some environment variables from the Docker container to the Windows inside the container. What should I do?

Docker compose

none

Docker log

none

Screenshots (optional)

No response

geekopslc avatar Oct 29 '24 15:10 geekopslc

There is a configuration in the file to modify the configuration of the data file to the local file (but I can't find which directory the data folder is mapped to in the system),There is also a way,Enter the file directory to use the temporary php website php -S 127.0.0.1:xxx Enter the system to access the host IP+ port to download,If you want to permanently access the website, you can try to use the Alist network disk,Mount the directory,You windows want to upload content directly to access the network disk, The network disk also supports uploading.

dengniqiu avatar Nov 12 '24 02:11 dengniqiu

@lcax200000 I think the easiest way would be to use https://github.com/dockur/windows?tab=readme-ov-file#how-do-i-run-a-script-after-installation to set this variables from a custom install.bat script.

kroese avatar Nov 12 '24 09:11 kroese

It has been solved by install.bat

geekopslc avatar Nov 14 '24 05:11 geekopslc

@Eric-3A setx variable value /m

kroese avatar Dec 06 '24 10:12 kroese

@Eric-3A setx variable value /m My requirement is to load environment variables every time the system starts up, not only when the system is newly installed, because I am using persistent storage, how do I implement loading environment variables every time the system starts up

Eric-3A avatar Dec 09 '24 06:12 Eric-3A

@Eric-3A See https://www.howtogeek.com/208224/how-to-add-a-program-to-startup-in-windows/ for a couple of methods to run a program at startup. You can just create a registry key for example.

kroese avatar Dec 09 '24 08:12 kroese

@Eric-3A See https://www.howtogeek.com/208224/how-to-add-a-program-to-startup-in-windows/ for a couple of methods to run a program at startup. You can just create a registry key for example.

It is ok to start some programs on the boot. I want to specify environment variables into the container when starting the windows container. My windows container uses persistent storage and does not need to install the system, so install.bat does not run on the installed system

Eric-3A avatar Dec 09 '24 09:12 Eric-3A

If it can start "some programs" you can also use it to run a command that sets a variable.

In any case, there is no easy way to do what you want. Also a lot depends on what purpose you need the variables for. Because if you just need to pass some outside information to the inside of the container, you can use the shared folder /data with a .txt file and run a program inside the container that reads from that text file. Or you can make the container do a web-request to a URL that returns the data.

kroese avatar Dec 09 '24 09:12 kroese