Passing environment variables from Docker container to Windows
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
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.
@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.
It has been solved by install.bat
@Eric-3A setx variable value /m
@Eric-3A
setx variable value /mMy 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 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.
@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
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.