Update / recreate image through API

I’m currently trying to interact with Portainer from my CI/CD tools.
That’s why I would like to update the image version of a running container through APIs.

This brings some questions:

  1. It seems there is no way to just update image through Portainer Rest API. Am I right ? I do understand that this part is managed by docker, but I had to check :stuck_out_tongue:

  2. I tried to do it by myself, by inspecting an existing container, and recreating it with the same parameters. At this time, only with API calls, I’m able to “edit” my container, replicating port bindings.
    But now, my problem is that I cannot get informations about ENV variables : containers inspection just doesn’t return them, when docker api documentation states it should be there.
    So my last question is : is it dependent of my docker engine ? Is there some kind of “filter” in portainer api ? Is there an another way to do it ?

Thank you for your answers, and sorry for my crap english !


AFAIK There is no specific API to hit that recreates a container and updates the image, we do this with multiple Api calls in the UI with a custom function.

Regarding your question on env vars, these are returned in the response of this Api call:

NOTE: replace <CONTAINER_ID> with the ID of your container.

I tested this with a container and they were correctly present in the JSON payload of the response.