There is NET CORE wrapper around docker (https://github.com/dotnet/Docker.DotNet)
It use strange abstraction to connection to docker
var client = new DockerClientConfiguration(new Uri("http://ubuntu-docker.cloudapp.net:4243")).CreateClient();
My docker is accessible from remote machine as
sudo curl --unix-socket /var/run/docker.sock http://157.XX.XX.84/v1.41/containers/json
What connection string I need to use with Docker.DotNet library and how to create needed authentication?
2
Answers
My question was about how exactly connect to remote socket and how to use basic AU to connect to remote socket. Documentation said nothing about this. So, this is my finally solution.
Remote socket is simple port 80. And without any AU. Therefore firstly I have created proxy server to protect remote socket by login-password. This is nginx config (in proxy mode).
Connection to remote docker is possible by this way
Docker.DotNet is not a high quality package and directly it not working (not only in my computer, I see a lot of issues from other programmers), so directly BasicAuthCredentials don't working. I assembly my program from source code of this package - NET CORE 5. How to fix "The located assembly's manifest definition does not match the assembly reference"?
And finally my program working fine. This is test of control docker by remote socket through proxy server with basic AU.
Docker Engine API
Docker provides an API for interacting with the Docker daemon , called the Docker Engine API which is a classic http rest api, with a lot of endpoints ready to use to for example: create container, images, start, delete, etc, This feature is used for all the docker clients in the world.
How to enable the Docker Engine http API
Basically the steps are: modify some docker internal configuration and restart the daemon. If you do that in a host 10.10.10.10 (remote docker host) you can invoke the api from any other host in the same network or with the respective permissions with something like this:
2375 is just for development. The optimum and secure is to configure the 4243 port
Sources:
.NET Client for Docker Remote API
This client as any other docker clients needs the docker http api url(as the most easy way), explained in the previous section
Also in the readme show that is possible to connect it using sockets intead http:
I don’t find if it allow us to use the insecure port 2375. SO you will have to enable the 4243 port on your remote docker host.
Anyway if you need a quickly test, you coul try with the 2375 port. Some issues show that port, so its possible that is allowed.
Advice