Installing Portus Docker registry on CentOS 7

Posted: September 30, 2018 in docker

Portus is open-source Docker registry where we can store and manage our Docker images.

Installing Docker/docker compose

wget -qO- https://get.docker.com/ | sh

The above command downloads and executes a small installation script written by the Docker team.

Add your user to the docker group with the following command.

sudo usermod -aG docker $(whoami)

Log out and log in from your server to activate your new groups.

Set Docker to start automatically at boot time:

sudo systemctl enable docker.service

Finally, start the Docker service:

sudo systemctl start docker.service

Install docker-compose

sudo yum install epel-release
sudo yum install -y python-pip

Then you can install Docker Compose:

sudo pip install docker-compose

Set hostname (needed for SSL certificate)

vi /etc/hostname
[root@docker secrets]# cat /etc/hosts
127.0.0.1 docker.com localhost.localdomain localhost4 localhost4.localdomain4

Clone Portus gitclone repositiry

git clone https://github.com/SUSE/Portus.git Install Self-signed certificate in Portus/examples/compose/secrets folder generate sertificates

openssl genrsa -des3 -out server.key 4096

openssl req -new -key server.key -out server.csr

cp server.key server.key.org

openssl rsa -in server.key.org -out server.key

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

mv server.crt portus.crt
mv server.key portus.key

1.PNG

0.PNG

Edit /Portus/examples/compose/nginx/nginx.conf (change hostname)

server {
listen 443 ssl http2;
server_name docker.com;
root /srv/Portus/public;

Edit /Portus/examples/compose/docker-compose.yml

Remove all links (exampe below)

links:
- db

links:
- portus:portus

Under nginx section add hostname variable:

nginx:
image: library/nginx:alpine
networks:
 default:
  aliases:
   - ${MACHINE_FQDN}

At the top of file add environment varaible

environment:
- CCONFIG_PREFIX=PORTUS

Edit /Portus/examples/compose/.env file, set MACHINE_FQDN

MACHINE_FQDN=docker.com

SECRET_KEY_BASE=b494a25faa8d22e430e843e220e424e10ac84d2ce0e64231f5b636d21251eb6d267adb042ad5884cbff0f3891bcf911bdf8abb3ce719849ccda9a4889249e5c2
PORTUS_PASSWORD=12341234
DATABASE_PASSWORD=portus

apply changes:

. .env

Run Portus image

docker-compose up -d

2.PNG

Test connection

I tested connection from Windows 10 machine, created a host record for linux Portus host

3.PNG

Set username/pass

4.PNG

Export sertificate to file.

5.PNG

Import certificate to Trusted root certification authority

5-1.PNG

5-2.PNG

Now Sertificate warning will go away.

Define Repository name

4-1.PNG

6.PNG

7.PNG

Pushing & Pulling images to/from Portus repository

C:\Users\ja>docker login docker.com
Username: admin
Password:
Login Succeeded

Tag image to point to Portus registry

tag docker4w/nsenter-dockerd:latest docker.com/registry:ncenter
docker push docker.com/registry:ncenter

8.PNG

Pulling same image from repository

C:\Users\ja>docker rmi docker.com/registry:ncenter
Untagged: docker.com/registry:ncenter
Untagged: docker.com/registry@sha256:2bcdfb81dab062c329a337218a70f48f0f2b973f47cd8afb7f7f96aa78d99a8c
C:\Users\ja>docker pull docker.com/registry:ncenter
ncenter: Pulling from registry
Digest: sha256:2bcdfb81dab062c329a337218a70f48f0f2b973f47cd8afb7f7f96aa78d99a8c
Status: Downloaded newer image for docker.com/registry:ncenter

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s