This repository contains the necessary files to build and run a secure Docker registry using basic authentication.
- Dockerfile: The Dockerfile used to build the Docker image for the secure registry.
- config.yml: The configuration file for the Docker registry.
- Docker installed on your system.
To build the Docker image, run the following command in the directory containing the Dockerfile
and config.yml
:
docker build -t myregistry:secure .
After building the image, you can run a container from it using the following command:
docker run -d -p 5000:5000 --name my-secure-registry myregistry:secure
This command runs the Docker registry on port 5000.
To log in to the secure Docker registry, use the following command:
docker login localhost:5000 -u myuser -p mypassword
To push an image to the secure registry, tag it with the registry's address and use the docker push
command. For example:
-
Tag the image:
docker tag your-image:latest localhost:5000/your-image:latest
-
Push the image:
docker push localhost:5000/your-image:latest
To pull an image from the secure registry, use the docker pull
command:
docker pull localhost:5000/your-image:latest
-
Build the Docker Image:
docker build -t myregistry:secure .
-
Run the Docker Container:
docker run -d -p 5000:5000 --name my-secure-registry myregistry:secure
-
Log in to the Registry:
docker login localhost:5000 -u myuser -p mypassword
-
Tag an Image:
docker tag hello-world:latest localhost:5000/hello-world:latest
-
Push the Image:
docker push localhost:5000/hello-world:latest
-
Pull the Image:
docker pull localhost:5000/hello-world:latest
If all steps complete successfully, your secure Docker registry is set up and working correctly.
- REGISTRY_AUTH: The authentication method. Set to
htpasswd
to use basic authentication. - REGISTRY_AUTH_HTPASSWD_REALM: The realm for basic authentication.
- REGISTRY_AUTH_HTPASSWD_PATH: The path to the htpasswd file.
These environment variables are set in the Dockerfile and used to configure the registry.
This project is licensed under the MIT License - see the LICENSE file for details.