MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Unable to create JNDI context for resolving SRV records

Getting this exception when trying to connect to MongoDB using SRV inside a Docker container (openjdk:8, driver version 3.7.0)

com.mongodb.MongoClientException: Unable to create JNDI context for resolving SRV records. The ‘com.sun.jndi.dns.DnsContextFactory’ class is not available in this JRE

As someone new to Java I have no idea what this means and there is zero documentation on how to solve this issue.