Unable To Delete A Tag When Running The Browser On A Different Host?

by ADMIN 69 views

Introduction

When working with Docker containers and registry browsers, it's not uncommon to encounter issues that can be frustrating to resolve. In this article, we'll explore a specific problem that occurred when trying to delete a tag using the Registry Browser on a different host. We'll delve into the error messages, log files, and configuration settings to identify the root cause of the issue and provide a solution.

The Problem

The Registry Browser is installed as a Docker container on a Network-Attached Storage (NAS) device, while the registry is running on a separate server. When attempting to delete a tag using the Registry Browser on the NAS, a 404 error is encountered, and the log file displays an error screen. However, when running the Registry Browser on the server where the registry is hosted, the tag deletion process works as expected.

Error Messages and Log Files

The log file contains the following error messages:

frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Started DELETE "/repo/sscm/management/tag/1.0.1?_method=delete" for 192.168.178.90 at 2025-05-03 07:23:15 +0000
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Processing by TagsController#destroy as TURBO_STREAM
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801]   Parameters: {"repo" => "sscm/management", "tag" => "1.0.1"}
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Completed 500 Internal Server Error in 1347ms (GC: 15.8ms)
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801]   
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Faraday::ResourceNotFound (the server responded with status 404):
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801]   
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] app/models/tag.rb:25:in 'Tag#delete'
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] app/controllers/tags_controller.rb:12:in 'TagsController#destroy'

Compose File Configuration

The Compose file configuration is as follows:

version: "3"
  services:
      frontend:
          image: klausmeyer/docker-registry-browser
          environment:
            - "SECRET_KEY_BASE=MY SECRET KEY"
            - "DOCKER_REGISTRY_URL=http://registry.MYSERVER.COM"
            - "ENABLE_DELETE_IMAGES=true"
            - "PUBLIC_REGISTRY=localhost:5000"
            - "BASIC_AUTH_USER=MYUSERNAME"
            - "BASIC_AUTH_PASSWORD=MYPASSWORD"
            - "REGISTRY_LOG_LEVEL=debug"
          ports:
            - "9874:8080"

Troubleshooting and Solution

After analyzing the error messages and log files, it appears that the issue is related to the PUBLIC_REGISTRY_URL environment variable. When set to http://registry.MYSERVER.COM, the tag deletion process fails with a 404 error. However, when set to localhost:5000, the process works as expected.

To resolve this issue, we need to ensure that the PUBLIC_REGISTRY_URL environment variable is set correctly. In this case, we can try setting it to the IP address of the server where the registry is hosted, instead of the hostname.

Step 1: Update the Compose File

Update the Compose file to set the PUBLIC_REGISTRY_URL environment variable to the IP address of the server where the registry is hosted:

version: "3"
  services:
      frontend:
          image: klausmeyer/docker-registry-browser
          environment:
            - "SECRET_KEY_BASE=MY SECRET KEY"
            - "DOCKER_REGISTRY_URL=http://registry.MYSERVER.COM"
            - "ENABLE_DELETE_IMAGES=true"
            - "PUBLIC_REGISTRY_URL=<IP_ADDRESS_OF_REGISTRY_SERVER>:5000"
            - "BASIC_AUTH_USER=MYUSERNAME"
            - "BASIC_AUTH_PASSWORD=MYPASSWORD"
            - "REGISTRY_LOG_LEVEL=debug"
          ports:
            - "9874:8080"

Step 2: Restart the Docker Container

Restart the Docker container to apply the changes to the Compose file:

docker-compose restart frontend

Conclusion

Q: What is the problem with deleting a tag when running the browser on a different host?

A: The problem occurs when the Registry Browser is installed as a Docker container on a Network-Attached Storage (NAS) device, while the registry is running on a separate server. When attempting to delete a tag using the Registry Browser on the NAS, a 404 error is encountered, and the log file displays an error screen.

Q: What are the error messages and log files related to this issue?

A: The log file contains the following error messages:

frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Started DELETE "/repo/sscm/management/tag/1.0.1?_method=delete" for 192.168.178.90 at 2025-05-03 07:23:15 +0000
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Processing by TagsController#destroy as TURBO_STREAM
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801]   Parameters: {"repo" => "sscm/management", "tag" => "1.0.1"}
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Completed 500 Internal Server Error in 1347ms (GC: 15.8ms)
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801]   
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] Faraday::ResourceNotFound (the server responded with status 404):
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801]   
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] app/models/tag.rb:25:in 'Tag#delete'
frontend-1  | [a40b0429-9c6a-4148-87c2-558b441f3801] app/controllers/tags_controller.rb:12:in 'TagsController#destroy'

Q: What is the Compose file configuration related to this issue?

A: The Compose file configuration is as follows:

version: "3"
  services:
      frontend:
          image: klausmeyer/docker-registry-browser
          environment:
            - "SECRET_KEY_BASE=MY SECRET KEY"
            - "DOCKER_REGISTRY_URL=http://registry.MYSERVER.COM"
            - "ENABLE_DELETE_IMAGES=true"
            - "PUBLIC_REGISTRY_URL=localhost:5000"
            - "BASIC_AUTH_USER=MYUSERNAME"
            - "BASIC_AUTH_PASSWORD=MYPASSWORD"
            - "REGISTRY_LOG_LEVEL=debug"
          ports:
            - "9874:8080"

Q: How I troubleshoot and resolve this issue?

A: To troubleshoot and resolve this issue, follow these steps:

  1. Update the Compose file to set the PUBLIC_REGISTRY_URL environment variable to the IP address of the server where the registry is hosted.
  2. Restart the Docker container to apply the changes to the Compose file.

Q: What are the common mistakes that can cause this issue?

A: The common mistakes that can cause this issue include:

  • Misconfiguring the PUBLIC_REGISTRY_URL environment variable.
  • Not updating the Compose file to reflect the correct IP address of the server where the registry is hosted.
  • Not restarting the Docker container after updating the Compose file.

Q: How can I prevent this issue from occurring in the future?

A: To prevent this issue from occurring in the future, make sure to:

  • Double-check the Compose file configuration to ensure that the PUBLIC_REGISTRY_URL environment variable is set correctly.
  • Update the Compose file to reflect any changes to the IP address of the server where the registry is hosted.
  • Restart the Docker container after updating the Compose file to apply the changes.