2

I was wondering is there a way to make a call to Docker API without docker daemon.

I went through their docs and a little bit of source code behind Docker CLI and couldn't find an answer.

I want to make a HTTP/HTTPS call to Docker API directly! I don't want to install docker CLI. Is this somehow possible and can you give an example?

EDIT:

I want to make Docker Registry API call without having to install docker to test credentials, which I would later use for docker login command.

Nikola Đuza
  • 455
  • 5
  • 11

2 Answers2

1

I think your question is a little confused. You can't make a call to the Docker API without the Docker daemon because the API is the daemon (or at least, the daemon exposes the API).

You can of course make requests to (control) the API / daemon without the Docker client though. Simply fire your requests at the socket (unix:///var/run/docker.sock) directly. Or if you want to expose it as HTTP(S recommended) then you can do this by altering the daemon startup options and instead send request over HTTP(S) to that address.

johnharris85
  • 17,264
  • 5
  • 48
  • 52
  • There are also lots of libraries in different languages to wrap this interaction, for instance docker-py for python. – johnharris85 May 19 '16 at 15:52
  • Thanks for your response. The problem is that I cannot have `docker daemon` on my machine. You're saying that API is only exposed through daemon and nowhere else? – Nikola Đuza May 20 '16 at 07:12
  • Also, I only need the `docker login` API call, can that be achieved without the daemon somehow? – Nikola Đuza May 20 '16 at 07:14
  • The daemon is the thing that does all the work. You need to connect to a daemon _somewhere_ for that to work. – johnharris85 May 28 '16 at 14:53
0

docker CLI <==[ Docker Engine API ]==> dockerd

The docker CLI communicates with a docker daemon using the Docker Engine API. The latest version is v1.41

The CLI and daemon don't need to be on the same machine. By setting the docker context, you can direct the docker CLI to communicate with a remote docker daemon, hence without installing Docker locally. Similarly, if you issue Docker Engine API calls using curl or any other SDK, you may use unix:///var/run/docker.sock for the local daemon (if installed), or the URL of the remote daemon.

dockerd <==[ Docker Registry API ]==> Docker Registry

The docker daemon communicates with a docker registry using the Docker Registry API. The latest version is v2. A docker pull alpine tells the daemon at the current context to issue a Docker Registry API call to the https://registry-1.docker.io/v2 endpoint at DockerHub, while docker pull registry.gitlab.com/username/image:tag tells the daemon to issue a Docker Registry API call to the https://registry.gitlab.com/v2 endpoint at your private GitLab container registry.

Craftonix - AA
  • 410
  • 5
  • 13