2.8 KiB
Configure Docker Desktop on Windows to use the proxy and trust its certificate
-
Let's say you set up the proxy on host
192.168.66.72
. Get the certificate using a browser (go to http://192.168.66.72:3128/ca.crt) and save it as a file (e.g., tod:\ca.crt
) -
Add the certificate to Windows:
- Double click the certificate
- Chose to Install certificate..., then click Next
- Chose Current user, then click Next
- Select option Place all certificates in the following store, click browse, and select Trusted Root Certification Authorities
- Proceed with Ok and confirm to install the certificate
If you are not using the WSL2 backend for Docker, then restart Docker Desktop and skip the next step.
-
If you are using WSL2 for Docker, then you need to add the certificate to WSL too:
-
Open a terminal
-
Check the name of the WSL distribution:
PS C:\> wsl --list Windows Subsystem for Linux Distributions: docker-desktop (Default) docker-desktop-data
The distribution we are looking for is docker-desktop. If you installed another distribution, such as Ubuntu, and configured Docker to use that, and proceed with that distribution instead.
-
Get a shell into WSL
PS C:\> wsl --distribution docker-desktop XXXYYYZZZ:/tmp/docker-desktop-root/mnt/host/c#
-
Copy the certificate into WSL and import it
Note: The directory and the command below are for the docker-desktop WSL distribution. On other systems you might need to tweak the commands a little, but they seem to be the same for Ubuntu and Debian as well.
XXXYYYZZZ:/tmp/docker-desktop-root/mnt/host/c# cp /mnt/host/d/ca.crt /usr/local/share/ca-certificates/ XXXYYYZZZ:/tmp/docker-desktop-root/mnt/host/c# update-ca-certificates WARNING: ca-certificates.crt does not contain exactly one certificate or CRL: skipping
Don't mind the warning, the operation still succeeded.
-
We are done with WSL, you can
exit
this shell
-
-
Configure the proxy in Docker Desktop:
- Open Docker Desktop settings
- Go to Resources/Proxies
- Enable the proxy and set
http://192.168.66.72:3128
as both the HTTP and HTTPS URL.
-
Done. Verify that pulling works:
# execute this in a Windows shell, not in WSL docker pull hello-world
You can check the logs of the proxy to confirm that it was used.
If pulling does not work and complains about not trusting the certificate then Docker and/or the WSL distribution might need a restart. You might try restarting Docker, or you can restart Windows too to force WSL to restart.