PyCharm Remote Interpreter and Docker: DNS Resolution Conflicts with IDE Certificate Validation
0 reputation · 19 Jun 2020, 20:43 UTC
0 reputation · 19 Jun 2020, 20:43 UTC
I am configuring PyCharm Professional (2024.x assumed) to use a Python remote interpreter running inside a Docker container on a private network. The container registry and internal package index sit behind a corporate proxy that presents a self-signed certificate, and the container's hostname is only resolvable through a custom DNS server set on the Docker daemon.
My understanding is that PyCharm relies on the host OS resolver for remote interpreter connections, while Docker containers may use DNS servers defined in the daemon or network configuration. At the same time, the IDE's HTTP client validates certificates against its own trust store (configurable under Settings | Build, Execution, Deployment), and there appears to be no GUI option to point that client at a custom DNS server or per-project hosts file.
It is unclear to me which resolver actually applies when the IDE connects to the containerized interpreter, and whether importing the proxy's self-signed certificate into the IDE trust store is sufficient for all IDE-originated traffic, or only some of it. Behavior may also differ between Community and Professional editions.
33275 reputation · 20 Jun 2020, 04:07 UTC
When PyCharm Professional (2024.x) creates a Docker‑based remote interpreter, the IDE uses the host OS resolver to look up the Docker daemon’s hostname or IP address. After the daemon returns the container’s IP address, PyCharm communicates with the container directly via that IP, so no further name resolution is performed by the IDE for the interpreter channel.
/etc/hosts entry). tcpdump -i any port 53 -w dns.pcap) and look for queries originating from the IDE process.--dns, or /etc/resolv.conf) are used only by processes inside the container (pip, conda, the Python interpreter)./etc/hosts)./etc/hosts or configure host DNS) so PyCharm can start the container.pip or conda running inside the container, also add the certificate to the container’s CA bundle (e.g., copy to /usr/local/share/ca-certificates/ and run update-ca-certificates) or set REQUESTS_CA_BUNDLE/PIP_CERT environment variables.docker inspect --format='{{json .HostConfig.Dns}}' <container-id> or docker exec <container> cat /etc/resolv.conf to confirm it points to your custom DNS server.idea.log for lines containing "Connecting to docker daemon" or "Resolving host" to confirm host‑side name resolution.To decide whether the host’s DNS (and thus the IDE trust store) is sufficient, please confirm: Is the internal package index accessed directly by PyCharm (e.g., via the IDE’s Packages UI) or only by pip/conda inside the container? If the IDE accesses it directly, host DNS and the IDE trust store must be correct; if only the container accesses it, you must ensure the container’s DNS and trust store are configured.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.