Skip to content

macOS: honor the active Docker context when /var/run/docker.sock is unavailable #537

Description

@Harsh4902

Describe the bug

microcks start cannot connect to Docker Desktop on macOS when Docker Desktop is configured without the privileged /var/run/docker.sock symlink.

Recent Docker Desktop installations can expose the daemon through the user-owned socket:

unix://$HOME/.docker/run/docker.sock

The Docker CLI continues to work because it resolves this endpoint from the active desktop-linux context. However, microcks-cli creates its Docker client using client.FromEnv. When DOCKER_HOST is unset, the Docker SDK falls back to:

unix:///var/run/docker.sock

This results in:

failed to create container: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Docker is running, and regular commands such as docker info and docker ps work correctly.

Expected behavior

microcks-cli should connect to the endpoint configured by the active Docker context, matching the behavior of the Docker CLI.
An explicitly configured DOCKER_HOST should continue to take precedence.

Actual behavior

microcks-cli tries unix:///var/run/docker.sock, even though the active desktop-linux context points to $HOME/.docker/run/docker.sock.

How to Reproduce?

  1. Install or configure Docker Desktop on macOS.

  2. In Settings → Advanced, leave Allow the default Docker socket to be used disabled.

  3. Ensure the Docker Desktop context is active:

$ docker context show
desktop-linux
  1. Verify the context endpoint:
$ docker context inspect desktop-linux \
    --format '{{ .Endpoints.docker.Host }}'
unix:///Users/<user>/.docker/run/docker.sock
  1. Confirm Docker works:
$ docker info
# succeeds
  1. Ensure DOCKER_HOST is not explicitly set:
$ unset DOCKER_HOST
  1. Start Microcks:
$ microcks start
failed to create container: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Microcks version or git rev

No response

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

No response

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions