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

How to set DOCKER_HOST on 4.13.0 without /var/run/docker.sock #6529

Closed
joshua-at-aws opened this issue Oct 21, 2022 · 25 comments
Closed

How to set DOCKER_HOST on 4.13.0 without /var/run/docker.sock #6529

joshua-at-aws opened this issue Oct 21, 2022 · 25 comments

Comments

@joshua-at-aws
Copy link

Expected behavior

  • DOCKER_HOST working in Docker Desktop 4.13.0

Actual behavior

Is there a different setting for DOCKER_HOST that will work in 4.13.0, or a preference to create the socket?
I poked around a bit but did not find anything in the UI. Thanks in advance!

Information

  • macOS Version: 12.6 Monterey
  • Intel chip or Apple chip: Intel
  • Docker Desktop Version: 4.13.0

Steps to reproduce the behavior

  1. Install 4.13.0 on Mac
  2. DOCKER_HOST not working
@nicks
Copy link

nicks commented Oct 21, 2022

Thanks for reporting!

We're trying to make Docker Desktop more userspace-friendly (e.g., fewer root privileges). As part of that, we're migrating the sockets to user-owned directories rather than root-owned directories (like /var/run).

Everything should work correctly if you unset DOCKER_HOST and let the default socket-picking behavior kick in?

There's supposed to be some shim code that fixes this automatically, let me check in with some people and get back to you.

@joshua-at-aws
Copy link
Author

Hi, thanks for the reply!

If I do unset DOCKER_HOST then the other tools, e.g. Maven or AWS SAM CLI do not work Error: Running AWS SAM projects locally requires Docker.

Could the new user-owned directory for the socket be added to the docs?

@nicks
Copy link

nicks commented Oct 21, 2022

Can you post a diagnostic id and the output of docker context list?

I think it's currently at ~/.docker/run/docker.sock, though I've been told that may change again. we're trying to get away from people hard-coding it.

@joshua-at-aws
Copy link
Author

joshua-at-aws commented Oct 21, 2022

  • Diagnostics ID: 8E63E195-B162-440D-826A-09E31E28D3A6/20221021210358
docker context list 
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                KUBERNETES ENDPOINT   ORCHESTRATOR
default *           moby                Current DOCKER_HOST based configuration   unix:///Users/joshuf/.docker/run/docker.sock                         swarm
desktop-linux       moby                                                          unix:///Users/joshuf/.docker/run/docker.sock     

Setting DOCKER_HOST to the default socket works! I see docker context list has a JSON output format, which I can use in a script if that's the new recommended way, for example with a Python one-liner:

docker context list --format json | python3 -c "import sys, json; j=json.load(sys.stdin); [print(x['DockerEndpoint']) if x['Current'] else None for x in j]"

unix:///Users/joshuf/.docker/run/docker.sock

@nicks
Copy link

nicks commented Oct 26, 2022

Our current plan is to roll this change back for now and figure out a more orderly upgrade path with docs for client library authors.

@hopeseekr
Copy link

Here is the workaround for OSX:

sudo ln -s "$HOME/.docker/run/docker.sock" /var/run/docker.sock

@hopeseekr
Copy link

I'd like to add that many thirdparty utilities, particularly IntelliJ and PhpStorm, expect there to be a /var/run/docker.sock. This change broke a wide swath of our toolchain.

@johndutchover
Copy link

Here is the workaround for OSX:

sudo ln -s "$HOME/.docker/run/docker.sock" /var/run/docker.sock

@hopeseekr I needed to force -f
sudo ln -sf "$HOME/.docker/run/docker.sock" /var/run/docker.sock

@tbeauvais-imagine
Copy link

This wasted 4 hours of my life thinking it was a configuration problem that I had.

As no valid configuration was found, execution cannot continue
Root cause NoSuchFileException (/var/run/docker.sock)

I appreciate the intent of this change, yet the intent should have been captured in the release notes. Also, with such changes, you should have a workaround available BEFORE release to ensure people can continue as necessary.

Still though, updated the DOCKER_HOST doesn't work since a lot of 3rd parties rely on the location of the sock descriptor since it has been there for a decade. To change it all of a sudden is really a really bold and strange call.

Hopefully, people find this (though I didn't) and don't waste hours like I did.

@johndutchover
Copy link

johndutchover commented Oct 27, 2022

This wasted 4 hours of my life thinking it was a configuration problem that I had.

As no valid configuration was found, execution cannot continue Root cause NoSuchFileException (/var/run/docker.sock)

I appreciate the intent of this change, yet the intent should have been captured in the release notes. Also, with such changes, you should have a workaround available BEFORE release to ensure people can continue as necessary.

Still though, updated the DOCKER_HOST doesn't work since a lot of 3rd parties rely on the location of the sock descriptor since it has been there for a decade. To change it all of a sudden is really a really bold and strange call.

Hopefully, people find this (though I didn't) and don't waste hours like I did.

updated post

Desktop 4.13.0 (89412) no longer hangs with "workaround", however I am not able to connect to Docker daemon . See steps taken below. Yes, previous release 4.12 does work on this setup.

My env:

  • macOS Version: 13.0 Ventura (previously didn't work in 12.6 Monterey)
  • Intel chip or Apple chip: Apple M1 Pro
  • Docker Desktop Version: 4.13.0,89412

Steps taken (zsh)

  • sudo ln -sf "$HOME/.docker/run/docker.sock" /var/run/docker.sock
  • add export DOCKER_HOST=unix://"$HOME/.docker/run/docker.sock" (note only two forward slashes after colon) to .zprofile
  • restart

Output after restart and login:
zsh ➜ docker version
Cannot connect to the Docker daemon at unix:///Users/username/.docker/run/docker.sock. Is the docker daemon running?
Client:
Cloud integration: v1.0.29
Version: 20.10.20
API version: 1.41
Go version: go1.18.7
Git commit: 9fdeb9c
Built: Tue Oct 18 18:20:35 2022
OS/Arch: darwin/arm64
Context: default
Experimental: true

unclear why "true" since set to false in $HOME/.docker/daemon.json

~
zsh ❯ docker context list
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * moby Current DOCKER_HOST based configuration unix:///Users/username/.docker/run/docker.sock swarm
desktop-linux moby unix:///Users/username/.docker/run/docker.sock

@johndutchover
Copy link

I found an issue when tailing file DockerAppStderr.txt in ~/Library/Group\ Containers/group.com.docker/DockerAppStderr.txt after launching 4.13.0 (89412):

time="2022-10-28T12:59:28Z" level="info" msg="GoBackend: notifying bugsnag: setting overrides for proxies: computing HTTPIP of 192.168.65.0/28: prefix of 28 does not accommodate a host numbered 128

I interpreted this to mean that the default Docker subnet (/28) subnet is too small.

Steps taken (in addition to #6529 (comment))

  1. Launch Docker Desktop 4.12.0 (85629)
  2. Navigate: Preferences -> Resources -> Network and changed subnet to /24

Screenshot 2022-10-28 at 9 24 35 AM

3. Updated in-app to 4.13.0 (89412)

And it's working!

potiuk added a commit to potiuk/airflow that referenced this issue Oct 28, 2022
Recent Docker Desktop (4.13.0) introduced a breaking (seriously)
change for new users where /var/run/docker.sock is removed.

They will likely restore it as result of backlash
docker/for-mac#6529 (comment)
but this change adds check and workaround that such users might
apply.

Related to: apache#27217
potiuk added a commit to apache/airflow that referenced this issue Oct 29, 2022
Recent Docker Desktop (4.13.0) introduced a breaking (seriously)
change for new users where /var/run/docker.sock is removed.

They will likely restore it as result of backlash
docker/for-mac#6529 (comment)
but this change adds check and workaround that such users might
apply.

Related to: #27217
@chaizeg
Copy link

chaizeg commented Oct 31, 2022

Closing this issue as a fix has been pushed with the new release of Docker Desktop 4.13.1. See release notes for more details.

@chaizeg chaizeg closed this as completed Oct 31, 2022
@kiwifellows
Copy link

  • export DOCKER_HOST=unix://"$HOME/.docker/run/docker.sock"

Amen is all I can say.... and when I read the "4 hours" yeap same here!! Almost
Updated my ~/.docker/init-zsh.sh with export DOCKER_HOST=unix://"$HOME/.docker/run/docker.sock"
Works

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

/lifecycle locked

@niklasschaeffer
Copy link

niklasschaeffer commented Mar 28, 2023

Thanks for reporting!

We're trying to make Docker Desktop more userspace-friendly (e.g., fewer root privileges). As part of that, we're migrating the sockets to user-owned directories rather than root-owned directories (like /var/run).

Everything should work correctly if you unset DOCKER_HOST and let the default socket-picking behavior kick in?

There's supposed to be some shim code that fixes this automatically, let me check in with some people and get back to you.

If someone find this in 2023

Hi, Docker-Desktop for Linux User here.
You can't just remove that without any backwards-compatibility flag or fix. PPL depend on /var/run/docker.sock in different scenarios. And literally running a link to this file after every restart is not the way. At least not for me.

this was the fix for me but literally took me hours to fiddle out.

/usr/lib/systemd/user/docker-desktop.service

[Service]
ExecStart=/opt/docker-desktop/bin/com.docker.backend && sudo ln -sf "/home/youruser/.docker/desktop/docker.sock" "/var/run/docker.sock" && sudo chmod 666 /var/run/docker.sock

kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Mar 30, 2023
Recent Docker Desktop (4.13.0) introduced a breaking (seriously)
change for new users where /var/run/docker.sock is removed.

They will likely restore it as result of backlash
docker/for-mac#6529 (comment)
but this change adds check and workaround that such users might
apply.

Related to: apache/airflow#27217

GitOrigin-RevId: 3e71c757affb5ce9373b3dea73ae699980165a4a
@tsal
Copy link

tsal commented Apr 3, 2023

This has returned in Docker 4.17.0; please provide clear documentation about the environment variable. Using sudo to create a symlink to a home dir for a user-land socket is not a safe option.

kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Apr 4, 2023
Recent Docker Desktop (4.13.0) introduced a breaking (seriously)
change for new users where /var/run/docker.sock is removed.

They will likely restore it as result of backlash
docker/for-mac#6529 (comment)
but this change adds check and workaround that such users might
apply.

Related to: apache/airflow#27217

GitOrigin-RevId: 3e71c757affb5ce9373b3dea73ae699980165a4a
@fharper
Copy link

fharper commented Apr 20, 2023

I'm also having this issue on a new laptop with Docker Desktop 4.18.0 (104112). My workaround was to create a symlink sudo ln -s "$HOME/.docker/run/docker.sock" /var/run/docker.sock

@Darkslide77
Copy link

Issue is still occurring, @fharper solution worked for me.

@niklasschaeffer
Copy link

niklasschaeffer commented Apr 21, 2023

@Darkslide77 @fharper

I literally found another working solution to this and this was by simply setting the DOCKER_HOST variable like so.

export DOCKER_HOST="unix://$HOME/.docker/desktop/docker.sock" of for your case probably
export DOCKER_HOST="unix://$HOME/.docker/run/docker.sock"

@fharper
Copy link

fharper commented Apr 24, 2023

@niklasschaeffer: nice, but it assume that apps connecting to the socket don't use default path, but use this environment variable no?

@niklasschaeffer
Copy link

niklasschaeffer commented Apr 24, 2023

@fharper As long as they respect the DOCKER_HOST Enviroment variable i think you won't have any problems at all

@fharper
Copy link

fharper commented Apr 24, 2023

@niklasschaeffer yeah, that's why I prefer to symlink. I would assume most people use the default path as it shouldn't NOT be created by Docker, instead of checking an environment variable that needs to be set by the user. Also, in my case, the app didn't check it :)

@adler-sudo
Copy link

This solves the issue without the need for root access

export DOCKER_HOST=unix://"$HOME/.docker/run/docker.sock"

@ataylormays-duetto
Copy link

I'm having this issue using docker desktop version 4.22.1. Running sudo ln -s "$HOME/.docker/run/docker.sock" /var/run/docker.sock fixes the issue, but as mentioned above this is not a great long-term solution, nor one that should require digging through closed issues to find a resolution for.

@nicks
Copy link

nicks commented Sep 7, 2023

Here's a good doc that explains sockets on Docker Desktop on Mac, and why we're moving away from the root-owned /var/run/docker.sock:
https://docs.docker.com/desktop/mac/permission-requirements/

@docker docker locked as resolved and limited conversation to collaborators Sep 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

15 participants