Updating ENV variables once container is running

Relatively new to Docker for Windows so I apologize ahead of time. Have some experience with Docker on a Synology and the two seem to react differently.

I’m running a minecraft server and have been asked to update the Forge version. When I set the server up originally it asked for the ENV Variable to be added, which was done. However now that I need to update, I can’t find the location of the ENV variable to go and update (to 40.2.9)

Synology just lets one edit the ENV once the container has been stopped. But for the life of me can’t find where I can edit this in Windows Docker. Or am I barking up the wrong tree here?


Found a fix with some more digging. Installed a Portainer.io container allows for some extra management of our containers and able to change/save/load the ENV variables from the portainer web GUI.

Bit of a kludge needing a container to manage the other containers to do this one specific job (as other docker apps do this natively), but hey, it works.

But if anyone has any cleaner fixes on how to change the variables using Windows Docker natively, that would be great!

What other Docker Apps?

Doesn’t Portainer just allows you to change the configuration and recreate the container? When I tried Portainer last time it was just a web interface for Docker Compose and Swarm services and also let you browse containers created outside Portainer.

IF it recreates the container you can do the same. The these variables are required by the processes inside the container and not the container itself, you need to stop the old process and start a new one. At least I don’t know any way to change the environment variables of a process.

It was only recently I heard about this feature of Synology, but I didn’t know you need to stop the container. Now it makes more sense to me. I just use Docker Compose and change the variable in the compose file and run docker compose up -d again so it recreates the container quickly which doesn’t really take more time then stopping and restarting the container.

Even if someone find a way without Synology to stop the Docker containerand change the compose container metadata, doing it in Docker Desktop would be much more complicated since everything runs in a virtual machine which runs multiple containers and only one of those is “docker” which is called “docker-02” recently if I remember corectly. AndI wouldn’t touch the virtual machine inside manually. I only entered the VM for learning purposes and sometimes for debugging.

When I need to edit configurations without recreating the container I use configuration files mounted to the container. This is how Nginx Proxy container works. ONe service listens to the docker api, generates new configuration file and reloads nginx.

In many cases when I see people want to edit variables without recreating the container the problem is they use Docker wrong. Maybe someone started the project and hard to change it. Obviously I would never recreate an entire virtual machine just to change an environment variable, but containers are different :slight_smile:

One more thought:

If I really have to change a variable in an existing project without recreating the container, I would edit the entrypoint script to export the variable overriding the one coming from the ENV instruction or compose. But I would also change the compose config or any config that creates the container so next time when the container is recreated, the same variable is passed.