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

Error trying to connect to Docker daemon socket when building #442

Closed
pinghedm opened this issue Jul 7, 2020 · 6 comments
Closed

Error trying to connect to Docker daemon socket when building #442

pinghedm opened this issue Jul 7, 2020 · 6 comments
Labels
enhancement New features, or improvements to existing features. linux The issue relates Linux support.

Comments

@pinghedm
Copy link

pinghedm commented Jul 7, 2020

Trying out the basic commands with the empty / default app. When running briefcase build, I get:

$ briefcase build

Ensure we have the linuxdeploy AppImage...
linuxdeploy-x86_64.AppImage already downloaded

[pub-ex] Building AppImage...

[pub-ex] Entering Docker context...
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Error while building app pub-ex.

This isn't really an error / fault of briefcase - it's because when I installed docker initially I didn't bother to do the post install step of making a new group so I could call docker without sudo (documented here: https://docs.docker.com/engine/install/linux-postinstall/ or the helpful SO answer here: https://stackoverflow.com/questions/21871479/docker-cant-connect-to-docker-daemon ).

But it is relatively common (judging by personal experience + number of similar stack overflow posts), maybe the error message could include a mention / link to that? Or the briefcase docs? Or mention the --no-docker flag? [The building docs here (https://docs.beeware.org/en/latest/tutorial/tutorial-3.html#building-your-application) mention that docker is used to build but it's relatively sparse - I only noticed the --no-docker flag grepping around in the source to see if I could hack in adding a sudo to the front of the docker commands just to get it to work]

@freakboy3742 freakboy3742 added enhancement New features, or improvements to existing features. linux The issue relates Linux support. labels Jul 7, 2020
@pinghedm
Copy link
Author

pinghedm commented Jul 7, 2020

If anyone has thoughts on what they would like, I'm happy to try adding error messaging or updating the docs! Or if it's felt this is not useful / not the responsibility of briefcase, totally understand!

@freakboy3742
Copy link
Member

Completely agreed - anything we can do to identify "obvious" sources of error and provide workarounds would be a welcome addition.

Docker is mentioned in the AppImage reference docs since that's the only backend that uses Docker. If we can elaborate on these docs, or link to them better, suggestions are welcome.

However the ideal outcome is to not need the docs at all (if only because nobody ever reads the the docs unless they absolutely have to :-).

Is it possible to perform a runtime check to detect if Docker is runnable without sudo? We have a number of pre-execution checks on various platforms, including a check that Docker is installed and is a sufficient version. If we can put a simple "try this command; if it failed with error code 42, print the error about making a sudo group", check at the start of the Docker commands, then that would be ideal.

@pinghedm
Copy link
Author

pinghedm commented Jul 7, 2020

Ah indeed I didn't read those docs ;)

Re: runtime check for Docker, yea should be able to. The dumbest thing I can imagine working quickly would be running any docker command (docker info for example) and checking the output (any command will throw the same permission denied if it's in this case).
The permission the process doesn't have is about reading a specific unix socket so there's also probably a nicer way as well; I'll do some reading and then try to wire that up to the existing checks you mention

@freakboy3742
Copy link
Member

That sounds ideal. One thing to keep in mind is that whatever approach you take, it also needs to work on macOS and Windows, so leaning too hard on Linux socket internals could be problematic. If invoking a "docker info" command gives you an identifiable error code, that would be ideal.

While you're in the area - it occurs to me that it might also be a good idea to check whether the docker daemon is actually running at all (ie., I have the right permissions, but the daemon has been stopped). I can imagine that would also be a likely source of error, and equally preventable - probably with the same docker info invocation (or something very similar).

@pinghedm
Copy link
Author

pinghedm commented Jul 7, 2020

Oh, yes both great points

I'm not 100% sure the same class of error does happen on those OS's (they both run docker differently with a VM intermediary, is my limited understanding? At least they don't have the equivalent steps in their install instructions in dockers docs) but point taken about it needing to be cross-platform regardless - adding a check that would just break on the other systems would not be good :).

The daemon not running at all is a great check too, I'll mess around with that too.

Alright I'll at least sketch out a solution with docker info to start!

pinghedm pushed a commit to pinghedm/briefcase that referenced this issue Jul 7, 2020
Code now uses a preflight `docker info` command to check the availabilty of docker commands.  Tested only on linux
Addresses issue beeware#442

Signed-off-by: Danny <danny@cultureiq.com>
@freakboy3742
Copy link
Member

Fixed by #443.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features. linux The issue relates Linux support.
Projects
None yet
Development

No branches or pull requests

2 participants