28 C
Dubai
Friday, November 22, 2024

Deploy a Container Image in a Linux VM

Container images are a lightweight, standalone, and executable software package that includes everything needed to run a piece of software: the code, runtime, system tools, libraries, and settings. These images are the foundation of container-based technologies like Docker, allowing applications to be abstracted from the underlying infrastructure.

  1. Portability: Container images are highly portable and can run consistently across different environments, including development machines, testing environments, and various cloud or on-premises platforms.
  2. Isolation: Containers provide isolation at the application level, allowing multiple containers to run on the same host without interference. Each container runs as an independent process with its own filesystem and resources.
  3. Layered Structure: Images are built in layers, allowing for efficient sharing of common components. When changes are made, only the affected layers need to be updated, reducing image size and improving speed in image distribution and deployment.
  4. Immutable and Reproducible: Container images are immutable, meaning they cannot be modified once built. This immutability ensures consistency and reproducibility across different environments.
  5. Dockerfile and Registries: Images are created using a Dockerfile, which defines the configuration and dependencies needed for the application. Images are stored and distributed via container registries such as Docker Hub, Azure Container Registry, or others.

Step 1 : Now lets create a Linux Virtual Machine and then deploy a Containerized Image in it.

The Linux is deployed, here I have allowed SSH and HTTP

Step 2 : Lets connect to the Linux Virtual Machine using Public IP, with the help of Putty Software.

Login to the Virtual Machine with your credentials.

Step 3 : Once we login into our VM, lets start updating the packages to set up an environment to install Docker in the system.

Use the below codes to create an environment to install Docker.

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Step 4 : Now the environment setup is done. Lets install Docker in the system by using the below code.

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Lets check whether Docker is installed or not.

Step 5 : Once you confirm that Docker is installed in the system. Now lets login to Docker account with your credentials.

Step 6 : Lets install and run, a containerized image in the system.

sudo docker run --name mynginx -p 80:80 -d nginx

Step 7 : Lets check whether in containerized image is published or not.

Successfully published the image in the Virtual Machine.

Santhosh M
Santhosh M
As a seasoned DevOps Engineer at Virtual Petals, I bring a wealth of expertise in Microsoft Cloud, DevOps, and the Microsoft 365 Stack. With a track record of delivering successful projects across the globe.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?