9 August, 2024
DevOps
Containerization is a technology used in software packaging, enabling developers to bundle an application and its dependencies into a standardized package for deployment. Containers operate in isolation from both each other and the underlying host system, which contributes to their lightweight and portable nature. Consequently, they are well-suited for deploying applications in cloud environments, where multiple containers can efficiently share resources.
Containerization offers several benefits when used for application setup on a local machine:
When comparing traditional setups with container-based setups on a local machine, there are several key differences:
Environment Isolation:
Resource Utilization:
Dependency Management:
Development Environment Consistency:
Deployment Flexibility:
Isolation and Security:
In summary, container-based application setups offer several advantages over traditional setups on local machines, including better environment isolation, resource utilization, dependency management, development environment consistency, deployment flexibility, and enhanced security. These benefits make containerization an attractive option for local development workflows, particularly in modern software development environments.
I will primarily focus on discussing two key container tools: Docker and Podman.
Docker and Podman are both containerization technologies that facilitate the packaging and execution of applications within isolated environments. They adhere to the Open Container Initiative (OCI) standards, allowing compatibility between container images created with one tool to be used with the other.
Docker is a well-established and widely adopted containerization technology. It boasts a robust community and an extensive ecosystem of tools and resources. However, Docker relies on a daemon-based architecture, necessitating a constantly running daemon process for container creation and management. This architecture can introduce security concerns and management complexities in certain scenarios.
On the other hand, Podman represents a newer generation of containerization technology known for its lightweight and secure approach. Unlike Docker, Podman operates as a daemonless system, eliminating the need for a continuously running daemon process. This design choice enhances security and simplifies management, particularly in specific environments.
Below is a comparative table highlighting key features of Docker and Podman:
Feature |
Docker |
Podman |
Ease of use |
More mature and user-friendly |
Less mature, but easier to secure |
Community support |
Larger community and ecosystem of tools and resources |
Smaller community, but growing rapidly |
Security |
Less secure due to daemon-based architecture |
More secure due to daemon less architecture |
Manageability |
More difficult to manage in some environments |
Easier to manage in some environments |
The best choice for you will depend on your specific needs and requirements. If you are looking for a mature and user-friendly containerization technology with a large community and ecosystem of tools and resources, then Docker is a good choice. If you are looking for a lightweight and secure containerization technology that is easy to manage, then Podman is a good choice.
We will be using docker for this example
Installing Docker on Linux (Ubuntu)
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] 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
Download the latest DEB package
wget https://desktop.docker.com/linux/main/amd64/149282/docker-desktop-4.30.0-amd64.deb
Install the package with apt as follows:
sudo apt-get update
sudo apt-get install ./docker-desktop-<version>-<arch>.deb
Installing Docker in Mac
Download the installer using the download buttons at the top of the page, or from the release notes(https://docs.docker.com/desktop/release-notes/).
Double-click Docker.dmg to open the installer, then drag the Docker icon to the Applications folder. By default, Docker Desktop is installed at /Applications/Docker.app.
Double-click Docker.app in the Applications folder to complete the Docker Installation.
Installing Docker in Windows
Download the installer using the download button at the top of the page, or from the release notes(https://docs.docker.com/desktop/release-notes).
Double-click Docker Desktop Installer.exe to run the installer. By default, Docker Desktop is installed at C:\Program Files\Docker\Docker.
When prompted, select WSL 2 or Hyper-V option on the Configuration page as per your choice of backend.
If your system only supports one of the two options, you will not be able to select which backend to use.
Follow the instructions on the installation wizard to authorize the installer and proceed with the installation.
I have created a GitLab repository with all the necessary files required. We can use those files to build Hybris version 2205.12 with SOLR version 8.11 & MySQL DB version 8.0. Below is our target setup.
Before doing this setup, make sure your system or docker-machine has enough resources. I would recommend at least 100GB disk space, 4 CPUs and 8GB RAM allocated to Docker.
Clone the GitLab repository
git clone https://gitlab.com/neocloudops-public/hybris_container_project.git
NB:
Build DB, SOLR & Hybris Images and run containers
cd hybris_container_project
docker compose up -d --build
Containers will get built and will start automatically. Verify the container logs to confirm the services are up & running properly.
If you check the app-db container logs, you should see a line saying:
[Server] /usr/sbin/mysqld: ready for connections
If you check the app-solr container logs, you should see a line saying:
INFO (main) [ ] o.e.j.s.Server Started
If you check the app-hybris container logs, you should see a line saying:
INFO: Server startup in **** ms
Now let’s restart the containers (Maybe you will get some errors in container startup in the above step, restart will fix those issues),
docker compose down && docker compose up –d --build
Once containers are up,
Open http://localhost:8983/solr/#/ for SOLR Admin.
Open http://localhost:8985 for PHPMyAdmin. Give `host` as `app-db` & `username/password `as `hybris/hybris` to login.
Open https://localhost:9002/ for Hybris HAC. Do a system Initialization with default settings. Once it is finished, you will be able to log in to HAC as an Admin user using `admin/admin` credentials.
Open the below URL for the default electronic store:
https://localhost:9002/yacceleratorstorefront/electronics/en/?site=electronics&clear=true
So, what is happening here is when you execute docker-compose up --build
, it looks at the configuration in docker-composer.yml
. In that file, it's specified to build an image for the Solr app, Db app & Hybris app containers. To do this, it reads the instructions from the Dockerfile
located inside the app-solr, app-db & app-hybris directories respectively. This file contains all the steps needed to create the image, like installing software or setting configurations. There's also a tool called phpMyAdmin included, which helps manage the database easily.
Once the images are created based on the instructions in these Dockerfiles, they are saved. Then, using the settings from docker-compose.yml
, Docker creates and starts containers using these saved images. In simpler terms, it's like following a recipe to bake a cake: you have the ingredients and instructions and following them step by step creates the final delicious cake!
In conclusion, by leveraging containerization technology, developers can streamline the setup process, create reproducible development environments, and accelerate the development cycle.
Furthermore, understanding the differences between traditional and container-based setups provides insights into the benefits of adopting containerization for local application development. Containerization enables developers to isolate applications and their dependencies within lightweight, portable containers, ensuring a consistent and efficient development experience across different environments. For a seamless setup of applications like SAP Hybris, SOLR, and MySQL on a local machine with containerization, developers can follow specific steps tailored to each application's requirements. By containerizing these applications, developers can create self-contained environments that include all necessary dependencies, configurations, and services, ensuring that the entire application stack works smoothly on a local machine.
In practice, setting up containers for SAP Hybris, SOLR, and MySQL involves creating Docker images for each application, defining Docker Compose configurations to orchestrate the containers, and ensuring proper networking and communication between the containers. With containerization, developers can easily manage dependencies, scale applications, and replicate production environments locally, facilitating efficient development and testing workflows.
Thanks for being part of this journey! I hope your deployments go well, your programs stay strong, and your creativity knows no bounds. Keep coding happily!