spring-boot: Error connecting to Docker daemon on macOS with Docker Desktop 4.13

When using Docker Desktop 4.13, the Maven spring-boot:build-image goal and Gradle bootBuildImage task might fail with an error message like this:

Connection to the Docker daemon at 'localhost' failed with error "[2] No such file or directory"; ensure the Docker daemon is running and accessible

via @trisberg and @danvega

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

When installing Docker Desktop on macOS, there is a setting to create both /var/run/docker.sock and /Users/<user>/.docker/run/docker.sock, with the first one being a link to the second one (the actual socket). That setting should make it so that the many tools relying on the standard Docker socket (/var/run/docker.sock) continue working without additional configuration. For the time being, it might be an idea to add that information to the Spring Boot documentation for Buildpacks.

docker-desktop-settings

Regarding defaulting Spring Boot to /Users/<user>/.docker/run/docker.sock for macOS, that would currently break the compatibility with Podman which is also affected by the socket change and is currently looking into a solution to support both in a transparent way (see issues here and here). It would be nice if there was a way for Spring Boot to use the current context automatically, whatever that is.

I’ve created #36445 to start using the Docker CLI context to determine the daemon host address to use. We’ll leave this issue open in case we need to address the /var/run/docker.sock vs $HOME/.docker/run/docker.sock default socket value when the default context is used.

Docker Desktop is now the default install on Linux as well as Mac. See https://docs.docker.com/desktop/install/linux-install

The differences in socket location and context now cause problems for users of Linux (and probably Windows) as well. Given that most users will be moving to Docker Desktop installations and probably using that UI for development, perhaps it would be a good idea to make an effort to improve build-image usability with Docker Desktop out of the box, without workarounds.

They’re going to roll the change back to give folks more time to adapt: https://github.com/docker/for-mac/issues/6529#issuecomment-1292135881