-1

I'm looking for a way to pull the latest image in Docker vanilla after a container crashed/exited.

As in my current architecture, I don't have access to Docker Engine API but only to the container itself, I want to be able to update the container based on the image after this service is exited.

The Docker way to upgrade containers seems to be the following:

docker pull mysql 
docker stop my-mysql-container 
docker rm my-mysql-container 
docker run --name=my-mysql-container --restart=always \
 -e MYSQL_ROOT_PASSWORD=mypwd -v /my/data/dir:/var/lib/mysql -d mysql

But that's based on the Docker engine CLI API and as I explained before - that's not an approach that I want to try.

Is there a possible way to configure the Docker when the container is pulling again the image from the latest repository upon restart/crash?

Daniel Chernenkov
  • 715
  • 1
  • 7
  • 23

1 Answers1

1

What you are asking for is this.

Which seems possible using docker service update for which you will need docker swarm. With plain docker installed on single VM, don't seems feasible.

Hope this helps.

mchawre
  • 10,744
  • 4
  • 35
  • 57
  • looks like there is no solution for what I'm looking for, I need to run a Docker command from inside the container – Daniel Chernenkov Jun 24 '19 at 12:16
  • Yes thats not possible. But if you want to run commands from within the docker container then use docker remote apis. Check this out https://stackoverflow.com/questions/56675083/getting-the-name-of-the-container-from-within-the-container/56682693#56682693 I have answered this earlier. – mchawre Jun 24 '19 at 12:25