Call Docker API without docker daemon - docker

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.

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.

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.

Related

Docker in Docker and AWS CLI for Windows Containers

I'm trying to migrate .NET legacy application to AWS ECS/Fargate. I'm following this article that explains how to create a custom Windows Docker image with MSBuild tools used in AWS CodePipeline/CodeBuild project. I also need to be able to install a Docker deamon and AWS CLIV2 into that custom image so that I could execute docker and AWS CLI commands in buildspec.yaml file in CodeBuild. So far I've been able to use this code in my custom image Dockerfile which installs Docker in Docker but the Docker service never gets started even though it understands docker --version command. I was also trying to modify this PowerShell script to install AWS CLI but also stuck with having little to no progress.
I'd appreciate any help in installing Docker in Docker and AWS CLI.
When I had to use docker in docker, I instead used the host docker socket by mounting that in the container.
I had to mount 2 files in linux.
/usr/bin/docker (executable)
/var/run/docker.sock (service socket)
Update - Above would work for linux, for windows, a double slash is required. Below socket would have to be mounted for windows. I couldn't personally test as I don't have windows.
"\\.\pipe\docker_engine:\\.\pipe\docker_engine"
I found a very good GUI tool explained this
Ref: https://tomgregory.com/running-docker-in-docker-on-windows/

How to deploy a Docker local registry open source on windows WITH web interface AND manage users permissions?

I'm novice in docker and I would like to deploy a docker private registry on my host (Windows10 usign docker for windows) with users permissions so I used TLS to securite it according to the doc from https://docs.docker.com/registry/deploying/
I have the docker private registry deployed and to push the user must do docker login command.
Now, I would like to connect a UI to my private registry and make it read only to be able to pull and for that I tried to setup Harbor, Portus and many other examples but they are not documented for windows.
I tried to use this project https://github.com/kwk/docker-registry-frontend but same thing.
All of these projects they bind files in volumes docker run -v pathToFiles:pathToFiles:ro but in windows it is not supported.
I tries to make modification in images and put the files into them and build a new images with docker commit but the UI still not work or not connected to my server.
So, what is the best way to deploy a docker private registry with the docker registry open source in docker for windows AND manage user permissions with auth ? Should I use a reverse proxy ? but how on windows?
I'm not using docker EE.
Thank you.

docker swarm http connectivity

new to docker and docker swarm. Trying docker and docker swarm both.
initially i had started a docker daemon and was able to connect it on http port i.e. 2375. I had installed docker colud plugin in jenkins and added http://daemon-IP:2375 and was able to create containers. well it creates a container, does my build inside it and destroys the container.
My Query is, will i be able to connect to docker swarm on http port, the same way i a am connecting to a standalone docker daemon ? is there any documentation on it. or the my understanding about the swarm is wrong.
please suggest.
Thanks
Yeah you can connect to a remote host the same way you are doing via the Unix Socket. People very often forget that docker is a client-server architecture and your "docker run..." commands are basically just commands issued by the docker client.
If you set certain environment variables:
DOCKER_HOST=tcp:ip.address.of.host:port
DOCKER_TLS_VERIFY=1
DOCKER_CERTS=/directory/where/certs/are
(The last two are optional for TLS connections, which I would highly recommend. You'd have to setup https://docs.docker.com/engine/security/https/ which is recommended for a production environment)
Once you've set your DOCKER_HOST environment variable, if you issue a docker command and get a response, it will be from the remote host if everything is setup correctly.

What is the Docker Engine?

When people talk about the 'Docker Engine' do they mean both the Client and the Daemon? Or is it something else entirely?
As I see it there is a Docker Client, a Docker Daemon. The Client runs locally and connects to the Daemon which does the actual running of the containers. The Client can connect to a remote Daemon. Are these both together the Engine? thanks
The Docker Engine is the Docker Daemon running on a single host, installed with the Docker Client CLI. Here are the docs that answer this specific question.
On top of that, you can have a Swarm running that joins multiple hosts to horizontally scale and provide fault tolerance. And there are numerous other projects from Docker, like their Registry, Docker Cloud, and Universal Control Plane, that are each separate from the engine.
Docker engine is a client-server application which comprises of 3 components.
1. Client: Docker CLI or the command line window that helps us to interact.
2. REST API: Client communicate with the server with REST API, the commands issued by the client is sent to the server in the form of REST API, it is this reason our server can either be in the local or remote machine.
3. Server: Server here is either the local or remote machine or host machine which has a daemon process running in it which receives the commands and creates, manages and destroys the docker objects like images, containers, volumes etc.

How to use docker remote api to create a container using another container's network namespace

I can run the following command to make a container using another container's network namespace:
docker run -it --net=container:<container_name> ubuntu:14.04
After running it, the two container have the same IP address. I want to know how to use the docker remote api or other client api to do it.
My docker server&client version is 1.10.3
docker run is basically docker create followed by docker start. You can find the documentation for the /containers/create endpoint in the API reference.
The property you're looking for is the NetworkMode in the HostConfig;
NetworkMode - Sets the networking mode for the container. Supported standard values are: bridge, host, none, and container:<name|id>. Any other value is taken as a custom network’s name to which this container should connect to.

Resources