Skip to content

Container registry workflow

A Container registry workflow involves the process of building container images from source code and distributing them to a remote registry, such as Docker Hub^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. This workflow enables developers to store versioned artifacts in a centralized repository, which can then be pulled by Container orchestration platforms like Kubernetes to deploy applications^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].

Build and Tag

The workflow typically begins with defining a Dockerfile that specifies the environment and dependencies for the application^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. Using the Docker CLI, the image is constructed locally. For example, to build an image named foo, one would run:

docker build -t foo .
^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md] After the build is complete, the image is often tagged with a specific registry username or repository path to prepare it for distribution^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].

Push to Registry

Once the image is built and tested locally, it is pushed to a remote registry^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. This step transforms the local artifact into a remotely accessible resource. Using Docker Hub as an example, the commands to tag and push are:

docker build -t mikehsu0618/foo . 
docker push mikehsu0618/foo
^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

By pushing the image to the registry, it becomes available for retrieval by other systems or users, facilitating the "convenience of containerization" where specific images and tags can be pulled on demand^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].

Deployment and Usage

In containerized environments, applications reference the images stored in the registry to ensure consistent deployments across different stages^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]. Within Kubernetes, the Pod specification defines the container image path, pointing directly to the registry to pull the required artifact^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].

spec:
  containers:
    - name: foo
      image: mikehsu0618/foo
      ports:
        - containerPort: 8080
^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]

Kubernetes retrieves the container images using the same mechanism as standard Docker workflows, pulling them from the registry to initialize the pods^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md].

Sources

^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]