Skip to content

Instantly share code, notes, and snippets.

Retrieving Docker Image Sizes

There are two metrics that are important to consider when discussing the size of Docker images.

  1. Compressed size - This is often referred to as the wire size. This affects how fast/slow images can be pulled from a registry. This impacts the first run experience on machines where images are not cached.
  2. Uncompressed size - This is often referred to as the size on disk. This affects how much local storage is required to support your Docker workloads.

The example commands shown below will work on Windows, MacOS, and Linux.

How to Measure the Compressed Size

@ChrisMcKee
ChrisMcKee / biggest_relations.sql
Created May 11, 2023 10:18 — forked from seejee/biggest_relations.sql
Postgres Maintenance Scripts
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
version: '3'
services:
db:
image: mysql:5.7
container_name: db
command: --lower_case_table_names=1
environment:
MYSQL_ROOT_PASSWORD: my_secret_password
MYSQL_DATABASE: capdb
@ChrisMcKee
ChrisMcKee / restoreDB.sql
Created March 29, 2021 16:42 — forked from RobsonAutomator/restoreDB.sql
restore RDS database from S3
-- Change [bucket] with your bucket name
exec msdb.dbo.rds_restore_database
@restore_db_name='Sitecore_Analytics',
@s3_arn_to_restore_from='arn:aws:s3:::[bucket]/Sitecore_Analytics.bak';
exec msdb.dbo.rds_restore_database
@restore_db_name='Sitecore_Core',
@s3_arn_to_restore_from='arn:aws:s3:::[bucket]/Sitecore_Core.bak';
@ChrisMcKee
ChrisMcKee / ShortIds.cs
Created August 24, 2020 16:38
Sizeable seed based ID
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace HashTime
{
class Program
{
@ChrisMcKee
ChrisMcKee / pack-man.ps1
Last active July 31, 2020 14:04 — forked from rjmurillo/pack-man.ps1
Useful Package Manager console commands
Get-Project –All | Add-BindingRedirect
# On large projects commands like `Update-Package -Reinstall` can take HOURS
# If the updates are broken up, then don't lock up the IDE and complete much faster (minutes vs hours)
# Reinstall all packages that match a specific targetFramework
# Useful when retargeting
gci -recurse packages.config | % { [xml]$XmlDocument = Get-Content -Path $_.FullName; $XmlDocument.packages.package | ? { $_.targetFramework -eq 'net462' } | select id | sort-object -unique | % { update-package -reinstall $_.id } }
# Reinstall all packages that have been marked with requireReinstallation
@ChrisMcKee
ChrisMcKee / upgrade-docker.sh
Created June 23, 2020 10:55
Upgrade docker to a specific version
#!/bin/bash
docker_version=19.03.11
pkg_version=$(apt-cache madison docker-ce | grep ${docker_version} | head -n 1 | cut -d ' ' -f 4)
apt-get install -y -q docker-ce=${pkg_version} docker-ce-cli=${pkg_version}
@ChrisMcKee
ChrisMcKee / uk-number-plate-validation.md
Created April 9, 2020 10:32 — forked from danielrbradley/uk-number-plate-validation.md
Regular Expression to Validate UK Number Plates

Regular Expression to Validate UK Number Plates

Regular Expression

(?<Current>^[A-Z]{2}[0-9]{2}[A-Z]{3}$)|(?<Prefix>^[A-Z][0-9]{1,3}[A-Z]{3}$)|(?<Suffix>^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(?<DatelessLongNumberPrefix>^[0-9]{1,4}[A-Z]{1,2}$)|(?<DatelessShortNumberPrefix>^[0-9]{1,3}[A-Z]{1,3}$)|(?<DatelessLongNumberSuffix>^[A-Z]{1,2}[0-9]{1,4}$)|(?<DatelessShortNumberSufix>^[A-Z]{1,3}[0-9]{1,3}$)|(?<DatelessNorthernIreland>^[A-Z]{1,3}[0-9]{1,4}$)|(?<DiplomaticPlate>^[0-9]{3}[DX]{1}[0-9]{3}$)

For use in JavaScript (with named groups removed):

(^[A-Z]{2}[0-9]{2}\s?[A-Z]{3}$)|(^[A-Z][0-9]{1,3}[A-Z]{3}$)|(^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(^[0-9]{1,4}[A-Z]{1,2}$)|(^[0-9]{1,3}[A-Z]{1,3}$)|(^[A-Z]{1,2}[0-9]{1,4}$)|(^[A-Z]{1,3}[0-9]{1,3}$)|(^[A-Z]{1,3}[0-9]{1,4}$)|(^[0-9]{3}[DX]{1}[0-9]{3}$)
@ChrisMcKee
ChrisMcKee / generate_new_kubeconfig.sh
Created March 29, 2019 12:51 — forked from Oats87/generate_new_kubeconfig.sh
This bash script will sign an x509 certificate using the kube-ca located on any rancher node. This allows you to gain access back to your RKE-created kubernetes cluster should you lose the kube_config and cluster.yml for it, but still have SSH access to the hosts.
#!/bin/bash
echo "This will generate a new kube config for accessing your RKE-created kubernetes cluster. This script MUST be run on a Kubernetes node."
echo "Please enter the IP of one of your control plane hosts, followed by [ENTER]:"
read cphost
openssl genrsa -out kube-admin.key 2048
openssl req -new -sha256 -key kube-admin.key -subj "/O=system:masters/CN=kube-admin" -out kube-admin.csr
sudo openssl x509 -req -in kube-admin.csr -CA /etc/kubernetes/ssl/kube-ca.pem -CAcreateserial -CAkey /etc/kubernetes/ssl/kube-ca-key.pem -out kube-admin.crt -days 365 -sha256
sudo rm -f /etc/kubernetes/ssl/kube-ca.srl
Follow the first few steps of https://rancher.com/blog/2018/2018-05-18-how-to-run-rancher-2-0-on-your-desktop/ in the docker-for-X UI to setup docker for kubernetes.
Pick a folder, open command prompt/terminal.
git clone git@github.com:jgreat/server-chart.git
kubectl -n kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller