Often you may need to pull a newer version of an image to re-create an existing container, and you don't care much about the checkpoints because the application is stateless.
The usual way of doing that is to use
docker pull repo/app
docker kill containerId
docker rm containerId
docker run --name xyz --link -v ... -p ... etc
This is quite tedious and requires to remember all the command line options that were used to start the container.
With k8s
or docker-compose
it is possible to solve that, but for vanilla Docker containers it could be tricky.
repull
simplifies it to the point of repull <containerid> <containername>...
.
It will
- iterate over the list of passed container ids or names
- fetch the description of the container
- identify the image used in the container
- lookup the information about the authentication in
~/.docker/config.json
- pull the new version of the image, if available for the current tag.
- kill the existing container
- remove the existing container
- start the new container with the newest image available preserving all configuration/startup options
- repeat for all images passed in the arguments.
$ docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $HOME/.docker/config.json:/.docker/config.json \
ghcr.io/jdevelop/repull:latest CONTAINER_NAME1 CONTAINER_NAME2 ... CONTAINER_NAMEN
$ go install github.com/jdevelop/repull
$ repull -h
./repull -h
Usage of ./repull:
-t int
timeout (seconds) (default 5)
-v verbose