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

Can dockerSocketPath be configurable, issues when socket is in different location. #1572

Open
valentincodes opened this issue Aug 29, 2024 · 4 comments

Comments

@valentincodes
Copy link

var dockerSocketPath = "/var/run/docker.sock"

Error: preparing build environment: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Socket location: /Users/<user>/.docker/run/docker.sock

@valentincodes valentincodes changed the title Can dockerSocketPath be made configurable, issues when socket is in different location. Can dockerSocketPath be configurable, issues when socket is in different location. Aug 29, 2024
@Adya-Prasad
Copy link

Can you please explain in some more detail!

@valentincodes
Copy link
Author

When running

doctl app dev build

I get
✔ fetching app details
✔ loading config from app ***
▸ current app dev workspace: ***
✔ preparing app dev environment
Error: preparing build environment: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Docker is running but location is /Users/<user>/.docker/run/docker.sock

@pedro-tl
Copy link

pedro-tl commented Nov 4, 2024

I am having the same issue. I've had it before with different projects due to the way Docker Desktop sets things up nowadays.

Creating a symlink to the local user socket solves it:
sudo ln -s /home/youruser/.docker/desktop/docker.sock /var/run/docker.sock

I can see the source code evals symlinks in the hardcoded path, unsure if the Docker Desktop installation was supposed to create it and failed, but it does work when the symlink is manually created.

@pedro-tl
Copy link

pedro-tl commented Nov 4, 2024

It seems the command still fails, albeit much further down the line now. I can see my app's build stage being completed, and the following error comes after that:

    ╭──────────── container image ───────────╼
    │  › creating app container image
    │ ERROR: failed to initialize docker client: failed to connect to docker socket: dial unix /var/run/docker.sock: connect: connection refused
    │ 
    │ command exited with code 1
    │  ✘ image creation failed
Error: command exited with a non-zero status code

I have tried with both the symlink and by prepending DOCKER_HOST to the command, like so: DOCKER_HOST=unix:///home/youruser/.docker/desktop/docker.sock doctl app dev build. Either combination of workarounds always results in the mentioned output.

This issue in buildpacks seems to hint that the export container fails to access the Docker daemon, due to non standard daemon socket location. One workaround in there is to run pack with the --docker-host=inherit flag, but there's no way for me to inject that flag into doctl's chain to test it. The issue has been open since Dec 1, 2021, so don't know if it is preferable to wait for it to be closed on buildpack's side, or detect this scenario and inject the flag on doctl's side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants