Ausnahme gefangen: SSL certificate problem: certificate is not yet valid 📌 Docker Registry Management

🏠 Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeiträge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden Überblick über die wichtigsten Aspekte der IT-Sicherheit in einer sich ständig verändernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch übersetzen, erst Englisch auswählen dann wieder Deutsch!

Google Android Playstore Download Button für Team IT Security



📚 Docker Registry Management


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

Introduction

A Docker registry is a place to store Docker images. There are two types of Docker registries

  • Private registry
  • Public registry

Docker Hub is a popular public registry, but organizations often prefer to use their own private registry to store and manage their images as it provides more control over image access and security.

Docker registry management involves pushing and pulling images from a registry, as well as managing access control, security, and versioning. To facilitate these tasks, various Docker registry management tools are available, such as Docker Trusted Registry, Harbor, and JFrog Artifactory

👉 In this post, I will be testing Docker-Hub repository, Nexus Repository and then apply GitHub actions to build an image automatically (CI)

Hands on Docker-Hub

💡 If you don't have a dockerhub ID, you can refer to the steps mentioned over here

After logging in to our account in Docker hub, we need to head to 'repositories' and select 'create repository'

Creat

Creating a private repository

Repo

Once the repository is created, we can confirm the repository name

Repo

Now back to our Linux terminal. I will be working on a new directory

mkdir /DockerFile_Root
cd /DockerFile_Root

Creating a simple test index.html file

cat "Test" > index.html

Creating a Dockerfile

vi Dockerfile

FROM nginx:latest
LABEL maintainer "Author <Author@localhost.com>"
ADD index.html /usr/share/nginx/html

Building this dockerfile

docker build -t mynginx:v1 ./

Successfully built a367f58de111
Successfully tagged mynginx:v1

Logging in to my docker hub

docker login
Username:
Password:
Login Succeeded

Pushing the image to our docker hub repository

docker tag mynginx:v1 waji97/myrepo:v1
docker push waji97/myrepo:v1

Deleting the local images and tags

docker rmi mynginx:v1
docker rmi waji97/myrepo:v1

Checking the repository from dockerhub

Image

Now we can start a docker container on our local machine using this image from our dockerhub

docker run -d --name Mynginx_1 -p 80:80 waji97/myrepo:v1
Unable to find image 'waji97/myrepo:v1' locally
v1: Pulling from waji97/myrepo
.
.
Status: Downloaded newer image for waji97/myrepo:v1
c3eeab8e250c18e472f105356790368253eb60991532d0b9b786829f94bf6bbe

👉 We can see that it pulled from my repository

Checking the docker process and images

docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                NAMES
c3eeab8e250c        waji97/myrepo:v1    "/docker-entrypoint.…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp   Mynginx_1

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
waji97/myrepo       v1                  a367f58de111        10 minutes ago      142MB

We can also visit our nginx server

Test

Hands on Nexus Repository

Nexus repository is a popular open-source repository manager developed by Sonatype. Nexus provides storing & managing software components, access control and integration with tools like Jenkins and Docker.

It was mainly used with Java projects and the repositories were accessible by an WEB UI. We will be using Nexus repository to build a private image repository using docker format.

There are three types of nexus repository:

  • Hosted: a private repository within a company (uploads are only possible locally)
  • Proxy: mirrors remote repositories (cache)
  • Group: groups various types of repositories together

Nexus

👉 Before starting the hands on, I recommend turning off swap memory using swapoff -a

We will start by creating a volume

docker volume create nexus_volume
nexus_volume

Next we will change the ownership for the data directory for this volume

chown 200:200 /var/lib/docker/volumes/nexus_volume/_data/

👉 We need to change this as not changing this could possibly incur push/pull errors later

Pulling the nexus image

docker pull sonatype/nexus3:latest

Now, we will create a new container for our nexus repo

docker run -d --name Nexus -p 8081:8081 -p 5000-5001:5000-5001 -v nexus_volume:/nexus-data sonatype/nexus3

👉 I would recommend to have atleast 3GBs of RAM in your host system for the above to actually run

docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                      NAMES
9c68a0f95437        sonatype/nexus3     "/opt/sonatype/nexus…"   3 seconds ago       Up 1 second         0.0.0.0:5000-5001->5000-5001/tcp, 0.0.0.0:8081->8081/tcp   Nexus

Now we need to copy the password from

cat /var/lib/docker/volumes/nexus_volume/_data/admin.password 

👉 Copy the password that is displayed

Navigating to the Nexus Repo Manager via our browser and logging in as 'admin' user

Admin

This will trigger a new 'change password' wizard. We can change our admin account password using this wizard

From settings, we will navigate to 'Blob Stores'

Blobs

Creating a new blob to use as docker-registry

Registry

Now heading to "Repositories" and clicking on "Create repository"

Create

We need to select 'docker(hosted)' from here and set up as following

Pull

After creating the above repository, we need to create another one named 'docker(proxy)'

P

Pu

Finally we will create our 'docker(group)' repository as well

Group

Adding all the members to our group

Group

Now from the "Security" section, we will navigate to Realms

Realm

Adding the "Docker Bearer Token Realm"

Realms

👉 Going back to our Linux terminal

We will add the following to our daemon JSON file

vi /etc/docker/daemon.json

"insecure-registries" : ["192.168.1.10:5000", "192.168.1.10:5001"]

💡 We had to add this as Nexus supports HTTPS but we are using HTTP

Reloading the daemon and restarting docker

systemctl daemon-reload
systemctl restart docker

docker start Nexus
Nexus

Now we can pull a test image for our nexus repository

docker pull 192.168.1.10:5000/hello-world
Using default tag: latest
latest: Pulling from hello-world
.
Status: Downloaded newer image for 192.168.1.10:5000/hello-world:latest

To confirm if this image was downloaded,

Nexus

We will perform another test by tagging our existing 'alpine' image to our nexus repository

docker tag alpine 192.168.1.10:5001/myalpine:v1

Logging in to our repository

docker login 192.168.1.10:5001
Username:
Password:
Login Succeeded

Pushing the tagged image to our repository

docker push 192.168.1.10:5001/myalpine:v1
The push refers to repository [192.168.1.10:5001/myalpine]
7cd52847ad77: Pushed 

# Logging out
docker logout 192.168.1.10:5001/myalpine:v1

Confirming this push from the WEB UI

UI

Hands on GitHub actions (CI)

GitHub Actions is a powerful CI/CD tool for automating software development workflows. It allows developers to automate tasks, build, test, and deploy code directly from GitHub.

  • Workflows are defined in YAML format and consist of Events and Jobs.
  • Events are triggers that execute a workflow.
  • Events can be configured to trigger on actions such as a push to a repository.
  • Workflows can contain multiple Jobs.
  • When multiple Jobs are present, parallel execution is the default behavior.
  • A Runner is required to execute Jobs and is typically a container.

✨ WorkFlow:-

  • Workflow: The entire workspace for building, deploying, and testing.
  • Event: The trigger for a Workflow to run (when it executes).
  • Job: The unit of work in a Workflow.
  • Step: Defines the sequence of tasks that a Job should perform.
  • Action: A pre-defined function (library) that performs a specific task. Runner: A containerized instance used to execute a Workflow.

Github Actions

👉 I will be doing a short hands on in which we will use Github actions to automatically create a docker image and push it to the dockerhub repository

From GitHub, we need to create a new repository for testing Github actions

Github

Now from DockerHub

Dockerhub

Now we will navigate to "My profile" => "Edit Profile" => "Security"

KDK

From this section, we will create a new access token with Read, Write and Delete permissions

Token

👉 Going back to Github

From our repository, we will head to settings and select

Actions

We will make 2 new secrets, one contains your DockerHub username and the other should contain the Access Token that we created from Dockerhub

Token

Now from our Github repository, we will create a new Dockerfile and also add a test html file

File

We will head to "Actions" and setup our custom workflow

Configure

My workflow YAML file looks like this

YAML

👉 This file will build an image and push it automatically to Dockerhub using Dockerfile present in the Github repository's main branch

Upon committing this file, we will have a new workflows folder in our repository

Workflow

We can also check our actions section

Dockerpush

To test if this actually worked, we will go to our Dockerhub repository

👉 Dockerhub test repository

Tag

We will test this image from our Linux Terminal now

Creating a container using our image from Dockerhub

docker login

docker run -d --name Mynginx_1 -p 80:80 waji97/testrepo:latest
latest: Pulling from waji97/testrepo
.
.
Status: Downloaded newer image for waji97/testrepo:latest
6bd35189a8261f80ed6763bd75f78cb0172bd21a0abcdb871ffb047c0d9e9729

Testing from the browser

WEB UI

👉 We will now try changing our index.html file from Github and commit so that Github actions can actually integrate this automatically

Upon committing the changes, we will be able to see a new workflow

Workflow2

Now from the Linux System, we will delete the container and the image.

After deleting the current image, we will pull the latest image from our Dockerhub repository and create a new container using the image to check our results

Final

✨ This is Continuous Integration

Conclusion

In conclusion, managing a Docker registry is an essential aspect of containerization. Dockerhub, Nexus Repository, and Github Actions CI are three popular options for Docker registry management, each with their own advantages and limitations ✔

...



📌 Docker users unhappy with latest forced login to download Docker and Docker Store images


📈 26.95 Punkte

📌 Mehrere Probleme in containerd, docker-runc, go1.11, go1.12, golang-github-docker-libnetwork, go und docker (SUSE)


📈 26.95 Punkte

📌 Security: Mehrere Probleme in containerd, docker-runc, go1.11, go1.12, golang-github-docker-libnetwork, go und docker (SUSE)


📈 26.95 Punkte

📌 Mehrere Probleme in containerd, docker-runc, golang-github-docker-libnetwork und docker (SUSE)


📈 26.95 Punkte

📌 Mangelnde Rechteprüfung in containerd, docker-runc, golang-github-docker-libnetwork und docker (SUSE)


📈 26.95 Punkte

📌 Docker Stack Tutorial | Docker Stack Deploy Docker-Compose.yml


📈 26.95 Punkte

📌 Preisgabe von Informationen in containerd, docker-runc, golang-github-docker-libnetwork und docker (SUSE)


📈 26.95 Punkte

📌 Preisgabe von Informationen in containerd, docker-runc, golang-github-docker-libnetwork und docker (SUSE)


📈 26.95 Punkte

📌 Denial of Service in containerd, docker-runc, golang-github-docker-libnetwork und docker (SUSE)


📈 26.95 Punkte

📌 Preisgabe von Informationen in containerd, docker-runc, golang-github-docker-libnetwork und docker (SUSE)


📈 26.95 Punkte

📌 Ausführen von Code mit höheren Privilegien in docker-runc, golang-github-docker-libnetwork, docker und containerd (SUSE)


📈 26.95 Punkte

📌 Mehrere Probleme in docker-runc, golang-github-docker-libnetwork, docker und containerd (SUSE)


📈 26.95 Punkte

📌 Security: Mehrere Probleme in docker-runc, golang-github-docker-libnetwork, docker und containerd (SUSE)


📈 26.95 Punkte

📌 CVE-2017-11468 | Docker Registry User Content resource management (RHSA-2017:2603 / Nessus ID 103039)


📈 25.48 Punkte

📌 Docker Registry Management


📈 25.48 Punkte

📌 Wise Registry Cleaner - Säuberung der Registry


📈 24.61 Punkte

📌 Wise Registry Cleaner - Säuberung der Registry


📈 24.61 Punkte

📌 Fonality Trixbox 2.0 Registry registry.pl privilege escalation


📈 24.61 Punkte

📌 Wise Registry Cleaner - Säuberung der Registry


📈 24.61 Punkte

📌 Wise Registry Cleaner - Säuberung der Registry


📈 24.61 Punkte

📌 Total Registry v0.96 releases: enhanced Registry editor/viewer


📈 24.61 Punkte

📌 Master the Windows Registry with Registry Editor in Windows 11


📈 24.61 Punkte

📌 Amazon Web Services führt Registry für Docker-Container ein


📈 21.29 Punkte

📌 Amazon Web Services führt Registry für Docker-Container ein


📈 21.29 Punkte

📌 Gitschooldude Video Tutorial: Introduction to Docker and the Gitlab Registry


📈 21.29 Punkte

📌 Klar - Integration Of Clair And Docker Registry


📈 21.29 Punkte

📌 Container Registry: Amazon startet Konkurrenz für Docker Hub


📈 21.29 Punkte

📌 Amazon plant eigene Container-Registry nach der Docker-Hub-Deckelung


📈 21.29 Punkte

📌 Docker Registry User Content Memory Consumption Denial of Service


📈 21.29 Punkte

📌 U.S. Dept Of Defense: Exposed Docker Registry at https://████


📈 21.29 Punkte

📌 registry Docker Image up to 2.7.0 improper authentication [CVE-2020-29591]


📈 21.29 Punkte

📌 CVE-2022-45385 | CloudBees Docker Hub Registry Notification Plugin up to 2.6.2 on Jenkins authorization


📈 21.29 Punkte

📌 Setup Docker Private Registry on Ubuntu


📈 21.29 Punkte

📌 Automate Docker Image Builds and Push to GitHub Registry Using GitHub Actions 🐙


📈 21.29 Punkte

📌 Alternative zu Docker Hub: AWS startet eigene Container-Registry


📈 21.29 Punkte











matomo