sudo yum install -y jq
git clone https://github.com/OtherDevOpsGene/k8s-tool-wrappers.git
git clone https://github.com/microservices-demo/microservices-demo
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
go install github.com/tilt-dev/ctlptl/cmd/ctlptl@latest
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
cd ~/environment/microservices-demo/deploy/docker-compose/
docker compose up
cd ~/environment/k8s-tool-wrappers/
sudo SKIP_AWS=true sh install.sh
cd ~/environment
export QUAY_PWD="pass"
skopeo login quay.io -u="otherdevopsgene" -p=${QUAY_PWD}
Skopeo works with Podman and Buildah.
skopeo inspect docker://docker.io/otherdevopsgene/hello-world-go | jq .
Before downloading, a lot of information in JSON format for easy parsing. I could extract the Digest with
skopeo inspect docker://docker.io/otherdevopsgene/hello-world-go:v0.2.0 | jq -r '.Digest'
I can also copy images, like a pull but into a local directory
mkdir hello-world-go-image
skopeo copy docker://docker.io/otherdevopsgene/hello-world-go dir:hello-world-go-image
This might be useful for scanning or doing a security analysis.
But this is better. Copy an image from one repo to another without storing it locally, ensuring the digest stays the same.
Show https://hub.docker.com/repository/docker/otherdevopsgene/hello-world-go/general
skopeo copy docker://docker.io/otherdevopsgene/hello-world-go:v0.2.0 docker://quay.io/otherdevopsgene/hello-world-go:v0.2.0 --dest-username otherdevopsgene --dest-password $QUAY_PWD
show https://quay.io/repository/otherdevopsgene/hello-world-go?tab=tags
Or even better:
skopeo sync --src docker --dest docker docker.io/otherdevopsgene/hello-world-go quay.io/otherdevopsgene --dest-username otherdevopsgene --dest-password $QUAY_PWD
refresh https://quay.io/repository/otherdevopsgene/hello-world-go?tab=tags
Crane can pull down the configuration of an image, basically all the Dockerfile info
crane config docker.io/otherdevopsgene/hello-world-go:v0.2.0 | jq .
It can also copy individual images like skopeo, either to a tarball or between registries.
But I most often use crane to list the tags:
crane ls docker.io/otherdevopsgene/hello-world-go
If you have a local registry running there is a crane catalog command to list all the repositories in the registry.
Crane also has ways to append tarballs to images and an experimental feature that lets you rebase an image with a different base image.
Dive is more for analyzing the layers of an image
dive docker.io/otherdevopsgene/hello-world-go:v0.2.0
Or on a less lean image
dive docker.io/otherdevopsgene/hello-world-server:latest
So you don't even have to pull it to a local dir like skopeo or a local tarball like crane.
The Slim toolkit has a bunch of features for interacting with and minimizing an image, but at it's basic, you just need to build a slim version from an existing image.
time slim build otherdevopsgene/hello-world-server
docker images otherdevopsgene/hello-world-server
docker images otherdevopsgene/hello-world-server.slim
345MB to 183MB -> almost a 50% savings
We can even use Dive to see a little bit about what happened:
dive otherdevopsgene/hello-world-server.slim
And we are down to a single layer.
If we have some containers running, say via docker-compose, we can see some stats on the memory and CPU usage, just like we can with the Unix top utility.
ctop
Use o
to view single container. q
to quit.