You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Docker Remote API with TLS client authentication via container
2
+
2
3
This images makes you publish your Docker Remote API by a container.
3
4
A client must authenticate with a client-TLS certificate.
4
-
This is an alternative way, instead of configuring TLS on Docker directly.
5
+
This is an alternative way, instead of [configuring TLS on Docker directly](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5).
6
+
7
+
## Remote Api with external CA, certificates and key
5
8
6
-
## Create CA, certificates and keys
7
9
First you need a CA and certs and keys for your Docker server and the client.
10
+
8
11
Create them as shown here [Protect the Docker daemon socket](https://docs.docker.com/engine/security/https/).
9
12
Or create the files with this script [create-certs.sh](https://github.com/kekru/linux-utils/blob/master/cert-generate/create-certs.sh). Read [Create certificate files](https://gist.github.com/kekru/974e40bb1cd4b947a53cca5ba4b0bbe5#create-certificate-files) for information on how to use the script.
10
13
11
-
## Start Container
12
-
Copy the following files in a directory. The directory will me mounted in the container.
14
+
Copy the following files in a directory. The directory will me mounted in the container.
15
+
13
16
```bash
14
-
ca-cert.pem
15
-
server-cert.pem
17
+
ca-cert.pem
18
+
server-cert.pem
16
19
server-key.pem
17
20
```
18
21
19
22
The files `cert.pem` and `key.pem` are certificate and key for the client. The client will also need the `ca-cert.pem`.
Now run the container with `docker-compose up -d` or `docker stack deploy --compose-file=docker-compose.yml remoteapi`.
24
39
Your Docker Remote API is available on port 2376 via https. The client needs to authenticate via `cert.pem` and `key.pem`.
40
+
41
+
## Remote Api with auto generating CA, certificates and keys
42
+
43
+
The docker-remote-api image can generate CA, certificates and keys for you automatically.
44
+
Create a docker-compose.yml file, specifying a password and the hostname, on which the remote api will be accessible later on. The hostname will be written to the server's certificate.
45
+
46
+
```yml
47
+
version: "3.4"
48
+
services:
49
+
remote-api:
50
+
image: kekru/docker-remote-api-tls:v0.2.0
51
+
ports:
52
+
- 2376:443
53
+
environment:
54
+
- CREATE_CERTS_WITH_PW=supersecret
55
+
- CERT_HOSTNAME=remote-api.example.com
56
+
volumes:
57
+
- <local cert dir>:/data/certs
58
+
- /var/run/docker.sock:/var/run/docker.sock:ro
59
+
```
60
+
61
+
Now run the container with `docker-compose up -d` or `docker stack deploy --compose-file=docker-compose.yml remoteapi`.
62
+
Certificates will be creates in `<local cert dir>`.
63
+
You will find the client-certs in `<local cert dir>/client/`. The files are `ca.pem`, `cert.pem` and `key.pem`.
64
+
65
+
## Setup client
66
+
67
+
See [Run commands on remote Docker host](https://gist.github.com/kekru/4e6d49b4290a4eebc7b597c07eaf61f2) for instructions how to setup a client to communicate with the remote api.
0 commit comments