Thoughts about Docker deleting unused images

zenulabidin

Ali Sherief

Posted on August 31, 2020

Thoughts about Docker deleting unused images

If you haven't heard already, Docker is planning to delete unused images. They have changed their Terms of Service to delete images on Docker Hub if nobody has used them for at least 6 months, and the uploader is using the Free plan. Of the 15 petabytes of container images hosted on Docker Hub, 4.5 petabytes of that are inactive containers. All of this is set to happen on November 1, 2 months from now.

This is the FAQ from Docker about resource consumption, if you want to read the official statement.

I believe Docker is trying to save money on operational costs by making this move, but this has implications for not only the people who own the inactive containers but don't want to pay up for a Docker plan, but also for the users who might find the containers online. Some of these images are indeed very valuable and can't be recreated easily, but the bigger problem, in my opinion, is If you want to share images, how will you do that without worrying about them getting deleted? That is the central question I will try to address here.

Option 1: Buy a paid plan

This may not be the most attractive option, but hey, it works. You get the other perks of a paid plan, and it immortalizes your images, at least until you stop paying and they become inactive again.

Option 2: Github Packages

I think this is the most reasonable alternative. Github Packages is fairly new, having been launched last year, that lets you publish any kind of release on it. It's not like publishing code on a repository, these are live bundles that are ready to be installed and used, the kind that are submitted to Rubygems and NPM. Natually this also extends to container images, so you can use Github Packages as a way to publish your packages, publicly and privately.

Packages

You can skip deploying to Docker Hub altogether and make the docker command send packages directly to Github Packages. That way you won't have to worry about losing your packages to inactivity.

This workflow publishes solely to Github Packages:

name: Publish Docker image
on:
  release:
    types: [published]
jobs:
  push_to_registries:
    name: Push Docker image to Github Packages
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
      - name: Push to GitHub Packages
        uses: docker/build-push-action@v1
        with:
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: docker.pkg.github.com
          repository: my-org/my-repo/my-image
          tag_with_ref: true
Enter fullscreen mode Exit fullscreen mode

This workflow publishes to both Github Packages and Docker Hub, and you'll probably benefit from having your images in both place during this transition period.

name: Publish Docker image
on:
  release:
    types: [published]
jobs:
  push_to_registries:
    name: Push Docker image to multiple registries
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
      - name: Push to Docker Hub
        uses: docker/build-push-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
          repository: my-docker-hub-namespace/my-docker-hub-repository
          tag_with_ref: true
      - name: Push to GitHub Packages
        uses: docker/build-push-action@v1
        with:
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: docker.pkg.github.com
          repository: my-org/my-repo/my-image
          tag_with_ref: true
Enter fullscreen mode Exit fullscreen mode

A little caution

Github Packages is a new service, and it's only keeping packages around forever because not many people have dumped containers on it yet. As soon as it overflows with petabytes of packages however, then Github might decide to purge inactive packages too if they are running out of space. But you don't need to worry about this, for the foreseeable future.

Then again, Github is owned by Microsoft so they could just make use of free Azure storage from them.

After all, Docker Hub also started off small like that with unlimited retention, until it grew into the large state it is today. So although storage space is advertised as unlimited to us, eventually, people run out of space behind the scenes.

💖 💪 🙅 🚩
zenulabidin
Ali Sherief

Posted on August 31, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related