Provides Docker, Kubernetes runtime and CLI tools for local development.
NOTE: you need either Docker Desktop (free for personal use) or Rancher Desktop (free). Pick one only.
Rancher Desktop Container Management and Kubernetes on the Desktop. Is the replacement for Docker Desktop. Use either one of them.
Download and install the latest binary for your platform from rancherdesktop.io. Unpack and move Rancher Desktop.app to /Applicationse.g., Rancher.Desktop-x.y.z.aarch64.dmg for Mac M1
Make sure you enabled following settings. ie., dockerd(moby) , PATH manual etc.
Docker Experimental Features
You can turn on experimental Docker CLI features in one of two ways. Either by setting an environment variable temporarily:
export DOCKER_CLI_EXPERIMENTAL=enabled
or by turning the feature on in the config file $HOME/.docker/config.json permanently:
{"experimental":"enabled"}
docker version should show Client > Experimental : true.
Optionally, You can also turn on docker engine's experimental features:
Change the docker engine configuration file /etc/docker/daemon.json or create one if it doesn’t exist already:
To SSH into lima VM managed by Rancher Desktop, run this command:
LIMA_HOME="$HOME/Library/Application Support/rancher-desktop/lima" "/Applications/Rancher Desktop.app/Contents/Resources/resources/darwin/lima/bin/limactl" shell 0
ls-la/etc/docker/# to restart docker daemon inside lima VMsudoservicedockerrestart
and added /etc/docker/daemon.json with the below settings.
Make sure dns, bip values match to your local network.
{"builder": {"gc": {"defaultKeepStorage":"20GB","enabled":true } },"features": {"buildkit":true },"experimental":false,"dns": ["your custom dns","8.8.8.8"],"bip":"192.168.254.1/24","insecure-registries": ["URL for your registry"]}
DevOps tools
Install optional DevOps tools for SREs
brewinstallkubectx# to switch kube context, namespace quickly. https://github.com/ahmetb/kubectxbrewinstallkubens# to switch kube quicklybrewinstallkubernetes-helm# package manager for Kubernetesbrewinstallkustomize# Kubernetes native configuration managementbrewinstallstefanprodan/tap/kustomizer# package manager for distributing Kubernetes configuration as OCI artifactsbrewinstallderailed/k9s/k9s# Manage Your k8s In Style!brewinstallistioctl# Istio configuration command line utilitybrew install dive # A tool for exploring a docker image, layer contents, and discovering ways to shrink the size of your Docker/OCI image
brewinstallcrane# A tool for interacting with remote images and registries.brewtapanchore/syft&&brewinstallsyft# SBOM toolbrewinstallcosign# Container Signing, Verification and Storage in an OCI registry.brewinstallskaffold# build and deploy docker imagesgoinstallsigs.k8s.io/bom/cmd/bom@latest# Create SPDX-compliant Bill of Materials
Usage
dockerinfodockerversiondockerstatsdockercontextlist# to use tools like dive, you may need to switch context to rancher-desktopdockercontextuserancher-desktopdockertopCONTAINERdockervolumelsdockernetworkls
# List builder instancesdockerbuildxls# inspect current builder instancedockerbuildxinspectdockerbuildximagetoolsinspect<MULTI_PLATFORM_IMAGE>dockerbuildximagetoolsinspect--rawnginx:alpine|jq
Images
dockerbuild.dockertagdockertagSOURCE_IMAGE[:TAG]TARGET_IMAGE[:TAG]dockerimagesdockerlogin-uaaaa-pbbb# Log in to your repository, I am using GitHub container registryexport GITHUB_PACKAGES_TOKEN=ghp_YOUR_TOKENdockerlogin-u{github_username}-p{[token](https://github.com/settings/tokens)}ghcr.io# inspect imagedockerinspectredislabs/redismod:edgedockerinspect--format"{{.Architecture}}"redislabs/redismod:edge# Remove one or more imagesdockerrmidocker.vectorized.io/vectorized/redpanda:v21.11.2# default from docker.iodockerpulljwsy/jade-shooter:v1.1dockerimages|grepjwsydockerrun-d-p8080:80jwsy/jade-shooter:v1.1dockerrun-d-p80:80--name=nginx--restart=alwaysnginx# `e2a5` is output from above commanddockerexec-ite2a5shdockerimages# save loaddockersave-olocal_jwsy_jade-shooter_v1.2.tardockerload-ilocal_jwsy_jade-shooter_v1.2.tar
# Generate a key-pair: cosign.key and cosign.pubcosigngenerate-key-pair# Export your COSIGN_PASSWORD to prevent CLI promptingexport COSIGN_PASSWORD=$COSIGN_PASSWORD
Sign the container image while pushing:
# Sign the image with Keyless modedockerpush--sign=cosigndevopps/hello-world# Sign the image and store the signature in the registrydockerpush--sign=cosign--cosign-keycosign.keydevopps/hello-world
Verify the container image while pulling:
# Verify the image with Keyless modedockerpull--verify=cosigndevopps/hello-world
# push firstdockerpush-ghcr.io/xmlking/grpc-starter-kit/base:v0.2.0# then sigh and verifyCOSIGN_EXPERIMENTAL=1cosignsignghcr.io/xmlking/grpc-starter-kit/base:v0.2.0COSIGN_EXPERIMENTAL=1cosignverifyghcr.io/xmlking/grpc-starter-kit/base:v0.2.0
Generate and upload the SBOM
We will use the syft to generate the SBOM and once its generated we will attach to image using cosign
# Let’s first generate the SBOMsyftpackagesghcr.io/junaid18183/sampleapp:0.0.1-ospdx>latest.spdxcosignattachsbom--sbomlatest.spdxghcr.io/xmlking/sampleapp:0.0.1
Dive
To explore docker image layers:
divespring-service:1.6.5-SNAPSHOT
Compose
dockercompose-finfra/redis.ymlupredisdockercompose-finfra/redpanda.ymlupredpandadockercompose-finfra/redpanda.ymllogsdockercompose-finfra/redis.ymldowndockercompose-finfra/redpanda.ymldown# this will stop redpanda and remove all volumesdockercompose-finfra/redpanda.ymldown-vdockercompose-finfra/redpanda.ymlps# name of the container can be found from output of above commanddockerexec-itinfra_redpanda_1/bin/bashdockerexec-itinfra_redpanda_1rpkversiondockerexec-itinfra_redpanda_1rpktopiclistdockerexec-itinfra_redpanda_1rpkclusterinfo# verify if docker `compose` getting correctly resolved application config from .envdockercomposeconfig# implicitly set `env-file` to `.env`dockercompose--env-file.env--env-file.secretsconfig# explicitly set `env-file` to `.env` and `.secrets`# ssh to container (if needed to debug)dockercomposeexec-itredpanda \rpk topicconsumetwitch_chat--brokers=localhost:9092# Ordockerexec-itredpanda-1 \rpk topicproducetwitch_chat--brokers=localhost:9092dockerexec-itredpanda-1 \rpk topicconsumetwitch_chat--brokers=localhost:9092