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

(bug): context not set for using docker-desktop #2901

Closed
schristoff opened this issue Sep 12, 2023 · 5 comments · Fixed by #2956
Closed

(bug): context not set for using docker-desktop #2901

schristoff opened this issue Sep 12, 2023 · 5 comments · Fixed by #2956
Labels
bug Oops, sorry! hacktoberfest Issues chosen for Hacktoberfest 2023 help wanted Good for someone who has contributed before

Comments

@schristoff
Copy link
Member

Describe the bug

When Porter tries to interact with Docker we get an error about the docker context needing to be set to default - if we are docker desktop users our context by default will be on docker-linux not default.

docker context ls
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/*****/.docker/run/docker.sock

Expected behavior

Users should not have to switch their docker context when using Porter. We should grab the current context during runtime. I think this is due to something being hardcoded in CNAB and how it is using docker, but I'm not sure.

@schristoff schristoff added bug Oops, sorry! help wanted Good for someone who has contributed before labels Sep 12, 2023
@schristoff
Copy link
Member Author

I think it's related to something here

@schristoff schristoff added the hacktoberfest Issues chosen for Hacktoberfest 2023 label Sep 23, 2023
@SoniaisMad
Copy link

Hello :)
i'm interested to try to fix this issue, can you assign me the issue if it's not already taken @schristoff ?

@matheuscumpian
Copy link

matheuscumpian commented Nov 9, 2023

Hi @SoniaisMad, are you currently working on this?

I was trying to reproduce the problem, I've both Docker CE and Docker Desktop in my Ubuntu and it seems that when we run porter build we got this error saying that we need to switch to the default context.

I've made some tests and it seems that just getting the current context from the users Docker solves the problem, I don´t know if I'm missing something, can you help me? @schristoff

bldr, err := builder.New(cli,
		builder.WithName(cli.CurrentContext()), --> I've changed this from "default" to the "current context"
		builder.WithContextPathHash(b.Getwd()),
	)

@SoniaisMad
Copy link

@HeavyBR Go ahead, i haven't started to work on this, so feel free to submit a PR.

@rayterrill
Copy link
Contributor

Ran into this and submitted a potential fix. ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Oops, sorry! hacktoberfest Issues chosen for Hacktoberfest 2023 help wanted Good for someone who has contributed before
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants