Docker daemon provides a Remote REST API. This API is used by the Client to communicate with the engine. This API can be also be invoked by by other tools, such as curl or Chrome Postman REST Client.

If you are creating Docker daemons using Docker Machine on OSX Mavericks, then getting this API to work is a bit tricky. This blog will explain how to enable Docker Remote API on Docker Machines created on Mac OS X.

Connecting to the secure Docker port using curl gives the command as:

Couple of issues with this command:

  • This command does not even work for Docker Machine since the certificates for each Machine are stored in .docker/machine/machines/ directory.
  • Even if this command is modified to match that path:

    It still gives the following error:

    The culprit for this is an updated curl utility for OSX Mavericks users. In summary, the new version of CURL uses Apple’s Secure Transport API instead of the OpenSSL API. This means the certificates need to be in P12 format.

Lets fix this!

  • Go to the directory where certificates for your Machine are stored. In my case, this is .docker/machine/machines/couchbase directory.
  • Generate *.p12 format for the certificate:
  • Now invoke the REST API as:

    Notice, --cert now points to the generated p12 certificate and certificate password is specified sing --pass.

    This will return the result as:

    OK, now that makes sense!

  • Lets try to start Couchbase server as:

    And invoke another REST API to view more details about this container:

Read through the complete API and go crazy now!

Originally posted at: Enabling Docker Remote API on Docker Machine on Mac OS X


Posted by Arun Gupta, VP, Developer Advocacy, Couchbase

Arun Gupta is the vice president of developer advocacy at Couchbase. He has built and led developer communities for 10+ years at Sun, Oracle, and Red Hat. He has deep expertise in leading cross-functional teams to develop and execute strategy, planning and execution of content, marketing campaigns, and programs. Prior to that he led engineering teams at Sun and is a founding member of the Java EE team. Gupta has authored more than 2,000 blog posts on technology. He has extensive speaking experience in more than 40 countries on myriad topics and is a JavaOne Rock Star for three years in a row. Gupta also founded the Devoxx4Kids chapter in the US and continues to promote technology education among children. An author of several books on technology, an avid runner, a globe trotter, a Java Champion, a JUG leader, NetBeans Dream Team member, and a Docker Captain, he is easily accessible at @arungupta.

Leave a reply