- .github
- cmd
- configuration
- digestset
- dockerfiles
- docs
- health
- internal
- manifest
- metrics
- notifications
- project
- registry
- releases
- tests
- testutil
- tracing
- vendor
- version
- .dockerignore
- .gitignore
- .golangci.yml
- .mailmap
- ADOPTERS.md
- AUTHORS
- BUILDING.md
- CODE-OF-CONDUCT.md
- CONTRIBUTING.md
- Dockerfile
- GOVERNANCE.md
- LICENSE
- MAINTAINERS
- Makefile
- README.md
- ROADMAP.md
- SECURITY.md
- blobs.go
- distribution-logo.svg
- doc.go
- docker-bake.hcl
- errors.go
- go.mod
- go.sum
- manifests.go
- registry.go
- tags.go
Explanation
The script tests if a Docker registry service, running at http://localhost:5001
, is available within one minute. It then attempts to push a “hello-world” image to the registry, pulling it before and after the push operation. Here’s a breakdown:
- Error Handling: The script sets
set +e
to ignore errors until the registry availability check is complete. - Registry Availability Check:
- It loops for 5 iterations, each with a 5-second delay.
- In each iteration, it uses
curl
to send an HTTP request to the/debug/health
endpoint of the registry and checks the HTTP status code. - If the status code is 200 (success), the loop breaks.
- If the loop completes without finding a successful response, the script exits with an error.
- Error Handling: The script sets
set -e
to resume normal error handling. - Image Operations:
- It pulls the “hello-world:latest” image.
- It re-tags the image to
$1:5000/distribution/hello-world:latest
, where$1
is the registry hostname passed as an argument. - It pushes the re-tagged image to the registry.
- It pulls the image again from the registry to verify the push operation.
Purpose: The script tests the functionality of a Docker registry by:
- Ensuring the registry is available and accessible.
- Pushing an image to the registry.
- Pulling the image from the registry to confirm successful push.
This script is likely used as part of a larger test suite for the distribution
project, which is a reference implementation of a Docker registry. It ensures that the registry’s basic functionalities like pushing and pulling images are working correctly.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph