Enable Docker Remote API on Docker Machine on Mac OS X

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/<machine-name> 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:
    More details here.
  • 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: blog.couchbase.com/2016/february/enabling-docker-remote-api-docker-machine-mac-osx

Be Sociable, Share!
  • Tweet

2 thoughts on “Enable Docker Remote API on Docker Machine on Mac OS X

  1. Machine working is great and it builds step by step. The nomnomtruck.com additionally take a shot at machine learning and the following time is likewise founded on machine learning.

  2. I found your website perfect for my needs. It contains wonderful and helpful posts. Keep up the good work! run 3

Leave a Reply

Your email address will not be published. Required fields are marked *