I have installed the Docker build step plugin for Jenkins.
The documentation is telling me:
Name : Choose a name for this Docker cloud provider
Docker URL: The URL to use to access your Docker server API (e.g: http://172.16.42.43:4243)
How can I find my URL to the REST API (I have Docker installed on my host)?
Here are two approaches.
How do I access the Docker REST API remotely?
Here is how I enabled it on Ubuntu 16.04 (Xenial Xerus).
/lib/systemd/system/docker.service
as it will be replaced on upgrades)For docker 18+, the content is a bit different:
Save the modified file. Here I used port
1111
, but any free port can be used.Make sure the Docker service notices the modified configuration:
Now you can use the REST API.
How do I access the Docker REST API through a socket (from localhost)?
Connect the internal Unix socket somewhat like this,
Using curl
And here is how to do it using PHP
In PHP 7 you can use curl_setopt with the CURLOPT_UNIX_SOCKET_PATH option.
It depends on your host, but look for
/etc/default/docker
or/var/lib/boot2docker/profile
(for Docker Machine hosts using a boot2docker VM).You will see the port used by the docker daemon, for instance:
Then get the IP address of the machine hosting your Docker daemon. (With a Docker Machine created host, that would be:
docker-machine ip <yourmachine>
.)The URL to use is the combination of those the IP address and the port.
If you are on Linux and need to connect to Docker API on the local machine, its URL is probably
unix:///var/run/docker.sock
, like it is mentioned in documentation: Develop with Docker Engine SDKs and APIThis might be helpful if you are connecting to Docker from a JetBrains IDE.
If you are on windows:
source: https://docs.docker.com/docker-for-windows/faqs/#how-do-i-connect-to-the-remote-docker-engine-api