Skip to content

beeglercorp/docker-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

Docker Utilities

This repository hosts utilities used by other repositories that build or manage Docker images.

Installing

  1. Add this repository as a git submodule.

    git submodule add https://github.com/beeglercorp/docker-util.git
  2. You probably don't care about the history, so configure the submodule to clone shallowly.

    git config -f .gitmodules submodule.docker-util.shallow true

Choosing a Version, and/or Updating

You may wish to use a particular version. To update the submodule to use a specific release (i.e. tag), run the following, making sure to replace {VERSION} with the version you desire.

cd docker-util
git fetch --tags
git checkout v{VERSION}
cd ../

If you prefer to use a branch, rather than a version (see above), periodically you will want to pull in the latest commits from the remote repository.

git submodule update --recursive --remote docker-util

Then, commit and push as usual.

Using a Utility

docker-util/sh/

attempt.sh

Use the attempt.sh script to register the attempt command. You may use this to retry fickle commands, such as docker version, that may fail during certain race conditions.

Usage
source docker-util/sh/attempt.sh && attempt <expression>
Example

The following will execute the docker login command up to 5 times, pausing 1 second in between attempts. If the docker login expression exits with a 0 status code during any of the attempts, the script will simply echo the expression's output. Otherwise it will log stdout and stderr, and exit with a 1 status code after the 5th attempt.

source docker-util/sh/attempt.sh && attempt docker login

compare-images.sh

Use the compare-images.sh script to compare 2 images by name. See the docker save documentation for valid IMAGE parameter values.

Usage
docker-util/sh/compare-images.sh <IMAGE> <IMAGE>
Examples
Success (exit 0)

The following will exit with a 0 status code if both foo and bar images exist, and the foo image produces an identical archive as the bar image.

docker-util/sh/compare-images.sh foo bar
Failure (exit 1)

The following all exit with a 1 status code.

# given _foo_ and _bar_ exist, but differ
docker-util/sh/compare-images.sh foo bar
# given the _foo_ image does not exist
docker-util/sh/compare-images.sh foo bar
# given the _bar_ image does not exist
docker-util/sh/compare-images.sh foo bar
# too few arguments
docker-util/sh/compare-images.sh foo
# too many arguments
docker-util/sh/compare-images.sh foo bar baz

install-docker-on-trusty.sh

Use the install-docker-on-trusty.sh script to update the Docker installation. You will typically run this in a Travis container, via .travis.yml.

Usage

.travis.yml

before_install:
  - ./docker-util/sh/install-docker-on-trusty.sh
  - sudo dockerd --experimental &

push-image.sh

Use the push-image.sh script to docker login and then docker push an existing, top-level image.

Usage
docker-util/sh/push-image.sh -i <image> -n <name> -p <password> -t [<tag>] -u <username>

test-image-size.sh

Use the test-image-size.sh script to test the size of an image, in MB, against a threshold.

Usage
docker-util/sh/test-image-size.sh -i <image> -t <threshold>
Example

The following will exit with a 0 status code if the foo image is less than or equal to 25MB. If the image is greater than 25MB, the script will exit with a 1 status code.

docker-util/sh/test-image-size.sh -i foo -t 25

validate-alpine-version.sh

Use the validate-alpine-version.sh script to ensure that your container runs on an expected Alpine version.

Usage
docker-util/sh/validate-alpine-version.sh -i <image> -v 3.6
Examples
Success (exit 0)

The following will exit with a 0 status code.

docker-util/sh/validate-alpine-version.sh -i beeglercorp/travis-cli:alpine-3.5 -v 3.5
Failure (exit 1)

The following will exit with a 1 status code.

docker-util/sh/validate-alpine-version.sh -i beeglercorp/travis-cli:alpine-3.5 -v 3.6

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages