From d970fa8af3b8d0178159c6dcc8167f90b97ac764 Mon Sep 17 00:00:00 2001 From: Mike Vanbuskirk Date: Mon, 21 Oct 2019 22:45:54 -0400 Subject: [PATCH 1/4] 828: clean up docker doc, fix context var in run cmd --- README.md | 100 +++++++++++++++++++++++++++-------------------- run_in_docker.sh | 10 ++--- 2 files changed, 63 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 13510dc2b..ec2a6de46 100644 --- a/README.md +++ b/README.md @@ -18,48 +18,53 @@ _If you are interested in contributing to kaniko, see [DEVELOPMENT.md](DEVELOPME **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [How does kaniko work?](#how-does-kaniko-work) -- [Known Issues](#known-issues) -- [Demo](#demo) -- [Tutorial](#tutorial) -- [Using kaniko](#using-kaniko) - - [kaniko Build Contexts](#kaniko-build-contexts) - - [Running kaniko](#running-kaniko) - - [Running kaniko in a Kubernetes cluster](#running-kaniko-in-a-kubernetes-cluster) - - [Kubernetes secret](#kubernetes-secret) - - [Running kaniko in gVisor](#running-kaniko-in-gvisor) - - [Running kaniko in Google Cloud Build](#running-kaniko-in-google-cloud-build) - - [Running kaniko in Docker](#running-kaniko-in-docker) - - [Caching](#caching) - - [Caching Layers](#caching-layers) - - [Caching Base Images](#caching-base-images) - - [Pushing to Different Registries](#pushing-to-different-registries) - - [Pushing to Amazon ECR](#pushing-to-amazon-ecr) - - [Additional Flags](#additional-flags) - - [--build-arg](#--build-arg) - - [--cache](#--cache) - - [--cache-dir](#--cache-dir) - - [--cache-repo](#--cache-repo) - - [--cleanup](#--cleanup) - - [--digest-file](#--digest-file) - - [--insecure](#--insecure) - - [--insecure-pull](#--insecure-pull) - - [--no-push](#--no-push) - - [--oci-layout-path](#--oci-layout-path) - - [--reproducible](#--reproducible) - - [--single-snapshot](#--single-snapshot) - - [--snapshotMode](#--snapshotmode) - - [--skip-tls-verify](#--skip-tls-verify) - - [--skip-tls-verify-pull](#--skip-tls-verify-pull) - - [--target](#--target) - - [--tarPath](#--tarpath) - - [--verbosity](#--verbosity) - - [Debug Image](#debug-image) -- [Security](#security) -- [Comparison with Other Tools](#comparison-with-other-tools) -- [Community](#community) -- [Limitations](#limitations) - - [mtime and snapshotting](#mtime-and-snapshotting) +- [kaniko - Build Images In Kubernetes](#kaniko---build-images-in-kubernetes) + - [How does kaniko work?](#how-does-kaniko-work) + - [Known Issues](#known-issues) + - [Demo](#demo) + - [Tutorial](#tutorial) + - [Using kaniko](#using-kaniko) + - [kaniko Build Contexts](#kaniko-build-contexts) + - [Using Private Git Repository](#using-private-git-repository) + - [Running kaniko](#running-kaniko) + - [Running kaniko in a Kubernetes cluster](#running-kaniko-in-a-kubernetes-cluster) + - [Kubernetes secret](#kubernetes-secret) + - [Running kaniko in gVisor](#running-kaniko-in-gvisor) + - [Running kaniko in Google Cloud Build](#running-kaniko-in-google-cloud-build) + - [Running kaniko in Docker](#running-kaniko-in-docker) + - [Caching](#caching) + - [Caching Layers](#caching-layers) + - [Caching Base Images](#caching-base-images) + - [Pushing to Different Registries](#pushing-to-different-registries) + - [Pushing to Docker Hub](#pushing-to-docker-hub) + - [Pushing to Amazon ECR](#pushing-to-amazon-ecr) + - [Additional Flags](#additional-flags) + - [--build-arg](#build-arg) + - [--cache](#cache) + - [--cache-dir](#cache-dir) + - [--cache-repo](#cache-repo) + - [--digest-file](#digest-file) + - [--oci-layout-path](#oci-layout-path) + - [--insecure-registry](#insecure-registry) + - [--skip-tls-verify-registry](#skip-tls-verify-registry) + - [--cleanup](#cleanup) + - [--insecure](#insecure) + - [--insecure-pull](#insecure-pull) + - [--no-push](#no-push) + - [--reproducible](#reproducible) + - [--single-snapshot](#single-snapshot) + - [--skip-tls-verify](#skip-tls-verify) + - [--skip-tls-verify-pull](#skip-tls-verify-pull) + - [--snapshotMode](#snapshotmode) + - [--target](#target) + - [--tarPath](#tarpath) + - [--verbosity](#verbosity) + - [Debug Image](#debug-image) + - [Security](#security) + - [Comparison with Other Tools](#comparison-with-other-tools) + - [Community](#community) + - [Limitations](#limitations) + - [mtime and snapshotting](#mtime-and-snapshotting) @@ -250,6 +255,17 @@ We can run the kaniko executor image locally in a Docker daemon to build and pus ./run_in_docker.sh ``` +**NOTE**: When running in Docker, Kaniko expects the absolute path to a +local build context, and a Dockerfile path _inside_ the container. + +An example run, specifying the Dockerfile in the container directory `/workspace`, the build +context in the local directory `/home/user/kaniko-project`, and a Google Container Registry +as a remote image destination: + +```shell +./run_in_docker.sh /workspace/Dockerfile /home/user/kaniko-project gcr.io/// +``` + ### Caching #### Caching Layers diff --git a/run_in_docker.sh b/run_in_docker.sh index 9397f1a71..562e881f7 100755 --- a/run_in_docker.sh +++ b/run_in_docker.sh @@ -15,7 +15,7 @@ #!/bin/bash set -e -if [ $# -lt 3 ]; then +if [ $# -lt 3 ]; then echo "Usage: run_in_docker.sh " exit 1 fi @@ -35,9 +35,9 @@ if [[ ! -e $HOME/.config/gcloud/application_default_credentials.json ]]; then fi docker run \ - -v $HOME/.config/gcloud:/root/.config/gcloud \ - -v ${context}:/workspace \ + -v "$HOME"/.config/gcloud:/root/.config/gcloud \ + -v $context:/workspace \ gcr.io/kaniko-project/executor:latest \ - --dockerfile ${dockerfile} --destination ${destination} --context dir:///workspace/ \ - --cache=${cache} + --dockerfile "${dockerfile}" --destination "${destination}" --context "${context}" \ + --cache="${cache}" From 53bf6c7339d3c88f4b18291f4a9aba3ae0a22984 Mon Sep 17 00:00:00 2001 From: Mike Vanbuskirk Date: Mon, 21 Oct 2019 23:15:11 -0400 Subject: [PATCH 2/4] 828: add "" to context var in vol mount switch --- run_in_docker.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/run_in_docker.sh b/run_in_docker.sh index 562e881f7..db106b273 100755 --- a/run_in_docker.sh +++ b/run_in_docker.sh @@ -36,7 +36,11 @@ fi docker run \ -v "$HOME"/.config/gcloud:/root/.config/gcloud \ +<<<<<<< Updated upstream -v $context:/workspace \ +======= + -v "$context":/workspace \ +>>>>>>> Stashed changes gcr.io/kaniko-project/executor:latest \ --dockerfile "${dockerfile}" --destination "${destination}" --context "${context}" \ --cache="${cache}" From d9c0c359eb6c554729ed41ae19e34e8b9f122337 Mon Sep 17 00:00:00 2001 From: Mike Vanbuskirk Date: Mon, 21 Oct 2019 23:16:33 -0400 Subject: [PATCH 3/4] 828: add "" to context var in vol mount switch --- run_in_docker.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/run_in_docker.sh b/run_in_docker.sh index db106b273..36496768e 100755 --- a/run_in_docker.sh +++ b/run_in_docker.sh @@ -36,11 +36,7 @@ fi docker run \ -v "$HOME"/.config/gcloud:/root/.config/gcloud \ -<<<<<<< Updated upstream - -v $context:/workspace \ -======= -v "$context":/workspace \ ->>>>>>> Stashed changes gcr.io/kaniko-project/executor:latest \ --dockerfile "${dockerfile}" --destination "${destination}" --context "${context}" \ --cache="${cache}" From 8f7eb00433284dc3312d40f9e12a94ef4dcbc3b0 Mon Sep 17 00:00:00 2001 From: Mike Vanbuskirk Date: Tue, 22 Oct 2019 17:39:37 -0400 Subject: [PATCH 4/4] 828: revert context to workspace, clean up doc --- README.md | 4 ++-- run_in_docker.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec2a6de46..21d6e17f5 100644 --- a/README.md +++ b/README.md @@ -255,8 +255,8 @@ We can run the kaniko executor image locally in a Docker daemon to build and pus ./run_in_docker.sh ``` -**NOTE**: When running in Docker, Kaniko expects the absolute path to a -local build context, and a Dockerfile path _inside_ the container. +_NOTE: `run_in_docker.sh` expects a path to a +Dockerfile relative to the absolute path of the build context._ An example run, specifying the Dockerfile in the container directory `/workspace`, the build context in the local directory `/home/user/kaniko-project`, and a Google Container Registry diff --git a/run_in_docker.sh b/run_in_docker.sh index 36496768e..ba95243bd 100755 --- a/run_in_docker.sh +++ b/run_in_docker.sh @@ -38,6 +38,6 @@ docker run \ -v "$HOME"/.config/gcloud:/root/.config/gcloud \ -v "$context":/workspace \ gcr.io/kaniko-project/executor:latest \ - --dockerfile "${dockerfile}" --destination "${destination}" --context "${context}" \ + --dockerfile "${dockerfile}" --destination "${destination}" --context dir:///workspace/ \ --cache="${cache}"