Access docker host from within container in docker beta

Expected behavior

access to docker host url

Actual behavior

did not work / nothing running at /var/run/docker.sock

Information

  • I am using the latest docker beta on osx
  • I want to forward the docker sock from osx into a jenkins container to spawn slaves
  • a connection via /var/run/docker.sock does not work
  • the docker-host-ip like 192.168.99.100 is not available in the beta

Steps to reproduce the behavior

  1. install the docker-plugin in a jenkins container like https://github.com/maxfields2000/dockerjenkins_tutorial
  2. configure the plugin`s docker-host-url
  3. test connection

What URL can I use to access the host’s docker-sock?

I’m wondering the same thing. I’d like to have my container access a debugger running on the host machine.

I notice that the container is on the 172.17.0.0 network and has an IP of 172.17.0.2. I can ping 172.17.0.1 which I assume is the host machine but can’t seem to access any ports on the host.

Probably something we need to do with docker-compose configuration. I to am coming from the boot2docker/Kitematic world.

I could be wrong but this might be mentioned in known limitations on the doc. Something sbout Mac networking which might have been this. Don’t remember and can’t look it up right now

I am having the same issue with Jenkins + Docker in Mac :confused:

At the docs, they say that is possible to share the docker.sock, but doesn’t works well

Namespaces
Much of the OS X file system that is accessible to the user is also available to containers using the -v bind mount syntax. You can share files in /Users, /Volumes, /private, and /tmp directly. For the Beta only, the rest of the user-accessible file system is mounted under /Mac. All other paths used in -v bind mounts are sourced from the Moby Linux VM running the Docker containers, so arguments such as -v /var/run/docker.sock:/var/run/docker.sock should work as expected.

https://docs.docker.com/docker-for-mac/osxfs/

Im facing the same problem here :confused: ! Some news about this problem?

I’ve had the same issue and just found that I need to run docker with sudo to access the mounted socket file.

$ docker run -it -v /var/run/docker.sock:/var/run/docker.sock my_container bash -c "sudo docker ps"

This works for me.

Here is the version of Docker I’m using.

Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      linux/amd64