Member-only story
Docker Registry with Basic Authentication
We set up a secure docker registry. Now we want to add authentication to this registry to prevent any unauthorized user from pushing any image to our registry. This will not be a role-based authentication we will set up Basic Authentication.
👉 Let’s create a directory named auth
using the mkdir
command. Here's how you can do it:
localhost:~$ mkdir auth
This command will create a directory named auth
in the current location. You can navigate to this directory using cd auth
if needed.
👉 Install htpasswd
if it's not already available.
- For Debian-based systems (like Ubuntu):
sudo apt-get update
sudo apt-get install apache2-utils
- For Red Hat-based systems (like CentOS):
sudo yum install httpd-tools
- For macOS (using Homebrew):
brew install httpd
👉 After installing htpasswd
, you can proceed with creating the password file as mentioned earlier:
localhost:~$ htpasswd -bnB megha password > auth/htpasswd
The command you provided will create a password file named htpasswd
in the auth
directory and store the username "megha" along with the hashed password in that file. Here's a…