Ici c'est l'exemple de l'instance DB-SRV sur le SINP PACA (silene.eu) qui est donné.
systemctl edit docker
[Service] ExecStart= ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://10.0.1.20:2376
vi /etc/systemd/system/docker.service.d/override.conf
systemctl daemon-reload
systemctl restart docker
systemctl status docker
vi /lib/systemd/system/docker.service
ExectStart=
en ajoutant l'option -H tcp://10.0.1.20:2376
juste aprés -H fd://
systemctl daemon-reload
systemctl restart docker
mkdir -pv /etc/docker/ssl/
chmod 600 /etc/docker/ssl/
cd /etc/docker/ssl/
openssl genrsa -aes256 -out ca-key.pem 4096
openssl req -new -x509 -days 1825 -key ca-key.pem -sha256 -out ca.pem
Country Name (2 letter code) [AU]: FR State or Province Name (full name) [Some-State]:Hautes-Alpes Locality Name (eg, city) []: Gap Organization Name (eg, company) [Internet Widgits Pty Ltd]: CBNA Organizational Unit Name (eg, section) []: SI Common Name (e.g. server FQDN or YOUR name) []: db-srv.silene.eu Email Address []: adminsys@silene.eu
openssl genrsa -out server-key.pem 4096
openssl req -subj "/CN=db-srv.silene.eu" -sha256 -new -key server-key.pem -out server.csr
echo subjectAltName = DNS:db-srv.silene.eu,IP:10.0.1.20,IP:127.0.0.1 > extfile.cnf
echo extendedKeyUsage = serverAuth >> extfile.cnf
openssl x509 -req -days 1825 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf
openssl genrsa -out key.pem 4096
openssl req -subj '/CN=client' -new -key key.pem -out client.csr
echo extendedKeyUsage = clientAuth > extfile-client.cnf
openssl x509 -req -days 1825 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile-client.cnf
chmod -v 0400 ca-key.pem key.pem server-key.pem
chmod -v 0444 ca.pem server-cert.pem cert.pem
mv key.pem client-key.pem
mv cert.pem client-cert.pem
vi /etc/docker/daemon.json
{ "tls": true, "tlsverify": true, "tlscacert": "/etc/docker/ssl/ca.pem", "tlscert": "/etc/docker/ssl/server-cert.pem", "tlskey": "/etc/docker/ssl/server-key.pem" }
systemctl stop docker.service;systemctl start docker.service
docker -H 10.0.1.20:2376 --tls --tlscert=/etc/docker/ssl/client-cert.pem --tlskey=/etc/docker/ssl/client-key.pem --tlscacert=/etc/docker/ssl/ca.pem ps -a
mkdir /home/admin/ca;cp /etc/docker/ssl/{ca.pem,client-*} /home/admin/ca/;chown admin: -R /home/admin/ca
scp admin@db-paca-sinp:~/ca/* ~/Documents/Keepass/docker-ca/db-srv/
rm -fR /home/admin/ca
mkdir -p /etc/docker/certs.d/db-srv
chmod 750 -R /etc/docker/certs.d/
mkdir /home/admin/ca;chown admin: -R /home/admin/ca
scp ~/Documents/Keepass/docker-ca/db-srv/* admin@bkp-paca-sinp:~/ca/
mv /home/admin/ca/* /etc/docker/certs.d/db-srv/
chown root: /etc/docker/certs.d/db-srv/*
rm -fR /home/admin/ca
chmod 640 /etc/docker/certs.d/db-srv/*