Setting up docker on the mac: Cannot connect via localhost

I’m just setting up docker on my Mac. The installation worked and I got some containers running (following the getting-stared guide), but now I want to connect with my browser to localhost, to show a web app.

For that I’m following this guide: https://docs.docker.com/engine/userguide/containers/usingdocker/

  • Assembly specified in the dependencies manifest was not found while running docker with dotnet-core project
  • Docker-swarm >> Cannot connect to the docker engine endpoint
  • Error travis on phpunit when I add docker login
  • Sklearn parallel processing not working in docker container
  • using docker for quick switching iojs version
  • Redirect different domains to the same apache using reverse proxy
  • In the last section it is said, that you simple go with your browser to: localhost:XXXXX wheras XXXXX is the port, that you found out using the command

    docker ps -l
    

    First problem: here nothing happends. The browser is showing an empty page (ERR_CONNECTION_REFUSED)

    Further more in the guide it is explained, that for Mac you can check your ip address via the command:

    docker-machine ip your_vm_name
    

    Here appears the second problem: This command results in an error-message:

    Host does not exist: "your_vm_name"
    

    So my questions are:

    How to set up the virtual machine (or “your_vm_name” respectively)?
    Does it have to do anything with the vhosts file on my Mac OS?
    Is there mybe a conflict with MAMP (which I’m also using sometimes)?

    Thanks in advance!

  • Docker image load failed?
  • Should the docker production image needs code as volume or not
  • How packaging and deployment works in Azure ?
  • Is it a docker best practice to use volume for the code?
  • Not able to execute RUN commands in Dockerfile
  • Possible differences between 2 identical Docker containers
  • 2 Solutions collect form web for “Setting up docker on the mac: Cannot connect via localhost”

    Hello the process to start to use docker on mac with docker-machine is like:

    Create a new docker machine on virtualbox, you can use a name like “your_vm_name” or just “default” in this way you can not use the name because “default” is a keyword that docker-machine try to use when you don’t specify nothing.

    The problem here is, why docker-machine ip your_vm_name doesn’t provide the good ip? Can you copy the result of your command

    echo $DOCKER_HOST
    

    Usually it’s 192.168.99.100
    thanks a lot

    And thanks to GianArb for the very fast answer! That solution works as well.

    Just to contribute to the community, I just found out by myself, that the solution was too simple to be true.

    Instead of your-vm-name use default (obviously the default-host that is set up by docker), so I just used:

    docker-machine ip default
    

    and then I got the right IP.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.