My nodejs/express application sends API calls from a server to a Portainer instance on a second, distant server. Portainer then creates/starts/stops/deletes docker containers on demand. Exactly as in Portainer's API docs, but using await/fetch. Works beautifully.
My docker containers use on their own env variables, set at the creation of the each container. Once the container is running though, changing any variables in the env seems difficult. From what I read, I understand I should destroy the container and recreate it with the updated env variables.
While according to Docker's API documentation some features of the container can be "updated" using and API call. Using a similar call to Portainer returns 200 (or "success"), but the container seems unaffected but the command:
const response = await fetch(
`https://portainer.${url}/api/endpoints/1/docker/containers/${containerId}/update`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify(containerConfig),
},
...
)
Is there any documented or undocumented way to modify the env variables and restart the container without destroying and recreating it ?
Thanks, Lorenzo