Docker

·

2 min read

1] Custom Docker Image

  • Create a docker image and push it to docker hub & ECR


2] File operations

  • Copy a file from host machine to a running container


3] Multi Stage Dockerfile

  • Write a Multi Stage Dockerfile for building and hosting a java application

  • Checkout the code from repository

  • copy the pom.xml & source code, then build a war file

  • Copy the war file and deploy it to a Tomcat environment


4] Docker File instructions

WORKDIR : it creates a directory and switches to that directory

USER : The USER instruction sets the user name or UID to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile

EXPOSE : it informs Docker that the container listens on the specified network ports at runtime

SHELL : it can be used more than once in a Dockerfile. All instructions that use a shell, and that come after a SHELL instruction, will use the new shell. Thus, you can change the shell multiple times in a single Dockerfile as needed


5] Jenkins Pipeline:

  • Create a Jenkins pipeline with the following stages;

    - Checkout Stage: Checkout the source code that contains the Dockerfile.

    - Build Stage: Build a Docker image using the Docker CLI.

    - Push Stage: Push the image to ECR.

    - Deploy Stage: Deploy the image to a Docker server as a container.


6] CGroups and Namespaces:

  • Understand the concepts of CGroups and Namespaces in Linux and their relevance to Docker.

cgroups and namespaces are powerful tools for managing resources and isolating processes in Linux systems.

They play a crucial role in system administration and containerization.

Cgroups, short for control groups, allow administrators to limit and distribute resources among different groups of processes.

Namespaces, on the other hand, create isolated environments for processes, separating them from the host system and other processes. Together, they provide a robust solution for resource management and isolation.