Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for reading docker context #1878

Merged
merged 2 commits into from
Sep 6, 2023

Conversation

jjbustamante
Copy link
Member

@jjbustamante jjbustamante commented Aug 28, 2023

Summary

This PR adds support to Pack for reading the docker HOST, to be used during the application build, from the current docker context saved at the home user directory.

Output

Before

When running pack build on Linux with Docker desktop installed, the following error was thrown:

ERROR: failed to build: failed to fetch builder image 'gcr.io/buildpacks/builder:latest': 
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Initially, this error could be workaround by:

  • Creating a symlink like sudo ln -s $HOME/.docker/desktop/docker.sock /var/run/docker.sock
  • Setting the DOCKER_HOST=unix://$HOME/.docker/desktop/docker.sock /var/run/docker.sock environment variable

After

Currently my docker context configuration is:

> docker context list
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                     KUBERNETES ENDPOINT   ORCHESTRATOR
default             moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
desktop-linux *     moby                Docker Desktop                            unix:///Users/jbustamante/.docker/run/docker.sock

I used to have the symlink but I removed it, now running pack build, pack will read from my local docker configuration file that desktop-liinux context is being used and then read the endpoint host from there and use it during the build, removing the previous error

looking for docker configuration file at: /Users/jbustamante/.docker
using docker context 'desktop-linux' with endpoint = 'unix:///Users/jbustamante/.docker/run/docker.sock'
Builder paketobuildpacks/builder:base is untrusted
As a result, the phases of the lifecycle which require root access will be run in separate trusted ephemeral containers.
For more information, see https://medium.com/buildpacks/faster-more-secure-builds-with-pack-0-11-0-4d0c633ca619
Pulling image index.docker.io/paketobuildpacks/builder:base
.... 

[exporter] Saving test-image:latest...
[exporter] *** Images (71f626605c5e):
[exporter]       test-image:latest
[exporter]
[exporter] *** Image ID: 71f626605c5e6b4e6883748395c589f1cec7ce8d4fe03c0703fedef67bab2a8b
[exporter] Reading buildpack directory: /layers/paketo-buildpacks_nginx
[exporter] Reading buildpack directory item: launch.toml
[exporter] Reading buildpack directory item: nginx.sbom.cdx.json
[exporter] Reading buildpack directory item: nginx.sbom.spdx.json
[exporter] Reading buildpack directory item: nginx.sbom.syft.json
[exporter] Reading buildpack directory item: nginx.toml
Successfully built image test-image:latest

Documentation

  • Should this change be documented?
    • Yes, see #___
    • No

Related

Resolves #1759
Resolves #1830

@github-actions github-actions bot added this to the 0.31.0 milestone Aug 28, 2023
@github-actions github-actions bot added type/enhancement Issue that requests a new feature or improvement. type/chore Issue that requests non-user facing changes. labels Aug 28, 2023
@jjbustamante jjbustamante force-pushed the bugfix/jjbustamante/issue-1759 branch 3 times, most recently from b14ac02 to bf40e7e Compare August 29, 2023 15:05
@jjbustamante jjbustamante added type/bug Issue that reports an unexpected behaviour. and removed type/enhancement Issue that requests a new feature or improvement. type/chore Issue that requests non-user facing changes. labels Aug 29, 2023
@jjbustamante jjbustamante marked this pull request as ready for review August 29, 2023 16:26
@jjbustamante jjbustamante requested review from a team as code owners August 29, 2023 16:26
@github-actions github-actions bot added type/enhancement Issue that requests a new feature or improvement. type/chore Issue that requests non-user facing changes. labels Aug 29, 2023
@jjbustamante jjbustamante modified the milestones: 0.31.0, 0.30.1 Aug 29, 2023
@github-actions github-actions bot modified the milestones: 0.30.1, 0.31.0 Aug 29, 2023
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
@jjbustamante jjbustamante modified the milestones: 0.31.0, 0.30.1 Aug 29, 2023
@jjbustamante jjbustamante removed type/enhancement Issue that requests a new feature or improvement. type/chore Issue that requests non-user facing changes. labels Aug 30, 2023
@github-actions github-actions bot added type/enhancement Issue that requests a new feature or improvement. type/chore Issue that requests non-user facing changes. labels Sep 6, 2023
@github-actions github-actions bot modified the milestones: 0.30.1, 0.31.0 Sep 6, 2023
@jjbustamante jjbustamante modified the milestones: 0.31.0, 0.30.1 Sep 6, 2023
@jkutner jkutner merged commit 2f00a05 into main Sep 6, 2023
17 checks passed
@jkutner jkutner deleted the bugfix/jjbustamante/issue-1759 branch September 6, 2023 14:45
@jjbustamante jjbustamante removed the type/enhancement Issue that requests a new feature or improvement. label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Issue that reports an unexpected behaviour. type/chore Issue that requests non-user facing changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pack should respect current docker context Support docker desktop on Linux
2 participants