Skip to content

Instantly share code, notes, and snippets.

@abessifi
Last active January 14, 2023 00:13
Show Gist options
  • Save abessifi/dfccaa83724375276f38c746ac3640e9 to your computer and use it in GitHub Desktop.
Save abessifi/dfccaa83724375276f38c746ac3640e9 to your computer and use it in GitHub Desktop.

Clone a testing project

cd /somewhere/

git clone https://github.com/docker/getting-started.git

cd getting-started/

mv Dockerfile Dockerfile.orig

vim Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
EXPOSE 3000

Dry-run build

podman run --rm \
  -v /somewhere/getting-started:/workspace \
  --security-opt label=disable \
  gcr.io/kaniko-project/executor:latest \
  --dockerfile=Dockerfile \
  --context=/workspace \
  --no-push

Build and push

podman run --rm \
  -v /somewhere/getting-started:/workspace \
  --security-opt label=disable \
  gcr.io/kaniko-project/executor:latest \
  --dockerfile=Dockerfile \
  --context=/workspace \
  --destination=<repo with image name>:<tag>

Access kaniko container to build and troubleshoot

podman run --rm -it \
  --entrypoint /bin/sh \
  -v /home/abessifi/RedHat/ORPEA/kaniko/getting-started:/workspace \
  --security-opt label=disable \
  gcr.io/kaniko-project/executor:debug
# If you run kaniko behind a proxy
# export HTTPS_PROXY=<proxy-address:proxy-port>

/workspace # /kaniko/executor --context=/workspace --dockerfile=Dockerfile --no-push

Example of build output

INFO[0000] Using dockerignore file: /workspace/.dockerignore 
INFO[0000] Retrieving image manifest node:18-alpine     
INFO[0000] Retrieving image node:18-alpine from registry index.docker.io 
INFO[0002] Built cross stage deps: map[]                
INFO[0002] Retrieving image manifest node:18-alpine     
INFO[0002] Returning cached image manifest              
INFO[0002] Executing 0 build triggers                   
INFO[0002] Building stage 'node:18-alpine' [idx: '0', base-idx: '-1'] 
INFO[0002] Unpacking rootfs as cmd COPY . . requires it. 
INFO[0064] WORKDIR /app                                 
INFO[0064] Cmd: workdir                                 
INFO[0064] Changed working directory to /app            
INFO[0064] Creating directory /app                      
INFO[0064] Taking snapshot of files...                  
INFO[0064] COPY . .                                     
INFO[0064] Taking snapshot of files...                  
INFO[0064] RUN yarn install --production                
INFO[0064] Initializing snapshotter ...                 
INFO[0064] Taking snapshot of full filesystem...        
INFO[0064] Cmd: /bin/sh                                 
INFO[0064] Args: [-c yarn install --production]         
INFO[0064] Running: [/bin/sh -c yarn install --production] 

yarn install v1.22.19
info No lockfilefound.
[1/4] Resolving packages...
[2/4] Fetching packages...                    
[3/4] Linking dependencies...                                                  
[4/4] Building fresh packages...

success Saved lockfile.
Done in 0.06s.

INFO[0065] Taking snapshot of full filesystem...        
INFO[0065] CMD ["node", "src/index.js"]                 
INFO[0065] EXPOSE 3000                                  
INFO[0065] Cmd: EXPOSE                                  
INFO[0065] Adding exposed port: 3000/tcp                
INFO[0065] Skipping push to container registry due to --no-push flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment