diff --git a/lib/datasource/docker/__snapshots__/index.spec.ts.snap b/lib/datasource/docker/__snapshots__/index.spec.ts.snap
index e828b7123836486c394cd3e3e37fbda6e29871d4..40b5985e56af2d05205d4398c2f2c1369a59f17c 100644
--- a/lib/datasource/docker/__snapshots__/index.spec.ts.snap
+++ b/lib/datasource/docker/__snapshots__/index.spec.ts.snap
@@ -392,7 +392,7 @@ Object {
 
 exports[`datasource/docker/index getRegistryRepository supports registryUrls 1`] = `
 Object {
-  "registry": "my.local.registry/prefix/",
+  "registry": "my.local.registry/prefix",
   "repository": "image",
 }
 `;
diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts
index f724fbc4ea64a5ca66aea269aed5a025f874286c..1d1f582083a00af83ca08d137c6301c27d1ba174 100644
--- a/lib/datasource/docker/index.ts
+++ b/lib/datasource/docker/index.ts
@@ -66,11 +66,12 @@ export function getRegistryRepository(
   registryUrl: string
 ): RegistryRepository {
   if (registryUrl !== defaultRegistryUrls[0]) {
-    const registry = registryUrl.replace('https://', '').replace(/\/?$/, '/');
-    if (lookupName.startsWith(registry)) {
+    const registry = registryUrl.replace('https://', '');
+    const registryEndingWithSlash = registry.replace(/\/?$/, '/');
+    if (lookupName.startsWith(registryEndingWithSlash)) {
       return {
         registry,
-        repository: lookupName.replace(registry, ''),
+        repository: lookupName.replace(registryEndingWithSlash, ''),
       };
     }
   }