A tool to restart a Docker container with a newer version of the image

repull

A tool to restart a Docker container with a newer version of an image used by the container

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

  1. iterate over the list of passed container ids or names
  2. fetch the description of the container
  3. identify the image used in the container
  4. lookup the information about the authentication in ~/.docker/config.json
  5. pull the new version of the image, if available for the current tag.
  6. kill the existing container
  7. remove the existing container
  8. start the new container with the newest image available preserving all configuration/startup options
  9. repeat for all images passed in the arguments.

Usage

./repull -h
Usage of ./repull:
  -v    verbose

Similar Resources

The Container Storage Interface (CSI) Driver for Fortress Block Storage This driver allows you to use Fortress Block Storage with your container orchestrator

fortress-csi The Container Storage Interface (CSI) Driver for Fortress Block Storage This driver allows you to use Fortress Block Storage with your co

Jan 23, 2022

Mutagen Compose is a modified version of Docker Compose that offers automated integration with Mutagen.

Mutagen Compose Mutagen Compose is a (minimally) modified version of Docker Compose that offers automated integration with Mutagen. This allows you to

Dec 22, 2022

Kubernetes workload controller for container image deployment

kube-image-deployer kube-image-deployer는 Docker Registry의 Image:Tag를 감시하는 Kubernetes Controller입니다. Keel과 유사하지만 단일 태그만 감시하며 더 간결하게 동작합니다. Container, I

Mar 8, 2022

Image clone controller is a kubernetes controller to safe guard against the risk of container images disappearing

Image clone controller image clone controller is a kubernetes controller to safe guard against the risk of container images disappearing from public r

Oct 10, 2021

Returns which registry from the container image name

Returns which registry from the container image name

Jan 23, 2022

Container image sweeper kube

container-image-sweeper-kube container-image-sweeper-kube は、不要になった Docker イメージを自

Jan 24, 2022

Undock - Extract contents of a container image in a local folder

Undock - Extract contents of a container image in a local folder

About Undock is a CLI application that allows you to extract contents of a conta

Jan 4, 2023

k8s-image-swapper Mirror images into your own registry and swap image references automatically.

k8s-image-swapper Mirror images into your own registry and swap image references automatically.

k8s-image-swapper Mirror images into your own registry and swap image references automatically. k8s-image-swapper is a mutating webhook for Kubernetes

Dec 27, 2022

This action prints "true" if image is required to update based on the base image update.

container-image-updater This action prints "true" if image is required to update based on the base image update. Inputs Name Type Description base-ima

Apr 15, 2022
Comments
  • build with latest docker api, fix go get issue

    build with latest docker api, fix go get issue

    • Fixes build issue with rename of Sirupsen/logrussirupsen/logrus
    • update docker api to v20
    • update remaining deps with go get -u all
    • improve call to containerWait() to wait on success & err
    • replace containerKill with containerStop

    BEFORE

    Go get was failing

    go get .
    go get: github.com/Sirupsen/logrus@none updating to
            github.com/Sirupsen/[email protected]: parsing go.mod:
            module declares its path as: github.com/sirupsen/logrus
                    but was required as: github.com/Sirupsen/logrus
    
    

    AFTER

    go get .
    # success!
    

    Testing

    unit suite

    $ go test .
    ok      github.com/jdevelop/repull      0.063s
    

    e2e

    $ docker restart watchtower
    $ pi@pi4plus:~/src/repull $ go run . -v watchtower
    DEBU[0000] inspecting container 9c1e389a60bfb5550f6df1e52305ff43aeb3681e1d941b0560aed94444a97d1c 
    DEBU[0000] pulling a new image for container 9c1e389a60bfb5550f6df1e52305ff43aeb3681e1d941b0560aed94444a97d1c : [/watchtower] 
    DEBU[0000] pulling image containrrr/watchtower          
    INFO[0000] using default tag: latest                    
    INFO[0001] received image id: sha256:3283e0b5be326d77ff4f4e8b7a91d46aaa1d511c74877b5a32f161548812d00c 
    DEBU[0001] stopping container 9c1e389a60bfb5550f6df1e52305ff43aeb3681e1d941b0560aed94444a97d1c : [/watchtower] 
    DEBU[0002] removing container 9c1e389a60bfb5550f6df1e52305ff43aeb3681e1d941b0560aed94444a97d1c : [/watchtower] 
    DEBU[0002] replacing image containrrr/watchtower with sha256:3283e0b5be326d77ff4f4e8b7a91d46aaa1d511c74877b5a32f161548812d00c 
    INFO[0003] started container f54560e7cd1369e26049dbc5564244cad9603b68c7ea079da65d64ef0c1ae20b 
    
  • Dockerfile for repull – add install and run via docker (no go needed)

    Dockerfile for repull – add install and run via docker (no go needed)

    • add a docker file to allow users to install / run from docker
    • updated readme with docker & golang install steps
    • docker image is only 9.2MB

    Bugs / Issues

    • the cli interface is clumsy needing docker socket & config.json mount.

    Building

    # build
    docker build . -t jdevelop/repull
    # test run
    docker run      \
       -v /var/run/docker.sock:/var/run/docker.sock\
       -v $HOME/.docker/config.json:/.docker/config.json   \
       jdevelop/repull -h
    # push to docker hub
    docker push jdevelop/repull
    

    Testing

    e2e

    $  docker run      -v /var/run/docker.sock:/var/run/docker.sock  -v$HOME/.docker/config.json:/.docker/config.json   tonymet/repull watchtower
    time="2021-08-29T18:50:48Z" level=info msg="using default tag: latest\n"
    time="2021-08-29T18:50:49Z" level=info msg="received image id: sha256:3283e0b5be326d77ff4f4e8b7a91d46aaa1d511c74877b5a32f161548812d00c"
    time="2021-08-29T18:50:49Z" level=info msg="started container 42c9e474d38b00abaeffb3290955de6520877f8df8561bbb372916c1fbc02509
    

    check image size = 9.2MB

    $ docker images |head
    REPOSITORY              TAG           IMAGE ID       CREATED         SIZE
    repull                  latest        dd34402d5857   17 hours ago    9.19MB
    
    
  • Implement the flag `-p` to print the docker command line that was used to create a container.

    Implement the flag `-p` to print the docker command line that was used to create a container.

    The flag -p shall instruct repull to generate the command line for docker command that will create the container with the same mount points, network configuration and links to other containers, as appropriate,

Bump-version - Bump a given semantic version, following a given version fragment

bump-version Bump a given semantic version, following a given version fragment.

Feb 7, 2022
Monitoring changes in the source file and automatically compile and run (restart).
Monitoring changes in the source file and automatically compile and run (restart).

dogo Monitoring changes in the source file and automatically compile and run (restart). 中文 Install go get github.com/liudng/dogo Create config Here's

Dec 28, 2022
Container-Explorer is a tool to explore containerd installation on a mounted image.

Container-Explorer Container-Explorer is a tool to explore containerd installation on a mounted image. Container-Explorer attempts to provide the simi

Dec 27, 2022
Vilicus is an open source tool that orchestrates security scans of container images(docker/oci) and centralizes all results into a database for further analysis and metrics.
Vilicus is an open source tool that orchestrates security scans of container images(docker/oci) and centralizes all results into a database for further analysis and metrics.

Vilicus Table of Contents Overview How does it work? Architecture Development Run deployment manually Usage Example of analysis Overview Vilicus is an

Dec 6, 2022
Dockpin - A tool for pinning Docker image and apt package versions

Dockpin Install dockpin with: go install github.com/Jille/dockpin@latest Dockpin

Dec 20, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

Dec 13, 2022
Tool to convert docker-compose files to set of simple docker commands

docker-decompose Tool to convert docker-compose files to set of simple docker commands. Install Use go get to install the latest version of the librar

Apr 12, 2022
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

Jan 8, 2023
Boxygen is a container as code framework that allows you to build container images from code

Boxygen is a container as code framework that allows you to build container images from code, allowing integration of container image builds into other tooling such as servers or CLI tooling.

Dec 13, 2021
Amazon ECS Container Agent: a component of Amazon Elastic Container Service
Amazon ECS Container Agent: a component of Amazon Elastic Container Service

Amazon ECS Container Agent The Amazon ECS Container Agent is a component of Amazon Elastic Container Service (Amazon ECS) and is responsible for manag

Dec 28, 2021