Setting up Dispatcher 2 on Docker (CentOS 7.x)

Singaiah Chintalapudi
4 min readJul 15, 2020

--

Authors

Singaiah Chintalapudi: https://www.linkedin.com/in/singaiah-chintalapudi-ph-d-a4a053122
Rahul Chugh: https://www.linkedin.com/in/rahulchug

Overview

This article describes setting up dispatcher 2.0 on Docker CentOS 7.x. Developers can use this image to easily setup their local dispatchers. It is always recommended to validate any functionality at the dispatcher level before promoting to deployment.

What is Docker?

Docker provides a OS (Operating System) -level virtualization to deliver the software as a modular/loosely coupled environments called containers. This is very powerful features and independent of host OS.

Prerequisites

  1. AEM author or publish server running on your local instance
  2. Installing Docker toolbox: https://docs.docker.com/toolbox/overview/
  3. Download and Install Visual Studio (VS)Code editor: https://code.visualstudio.com/

Setup

Note: You can configure docker on all operating systems including Windows, Mac, and others.

  1. Make sure you’ve installed the Docker toolbox and configured AEM publish server running on your computer
  2. Download the Docker image file by executing:

docker pull singaiah/dispatcher2-on-centos7:latest

3. Open the VS code editor and go to Extensions and install Docker extension

Installing Docker extension for VS Code editor

4. After you install the Docker extension, you’ll see the Docker icon on the left side in the VS code editor. Click on that Docker icon. Here you can see all the images and running containers.

Starting Docker image in a container

5. Right click on the image i.e. singaiah/dispatcher2-on-centos:latest and click on run interactive. Once the image is started then you see the container in the container section.

Starting Docker container

Note: Default ports are 80:80. When you start the container in the VS code, it uses the above highlighted command to start the container. You can always change those ports.

6. Now, we need to make few changes to make it work. Right click on your container (in the Containers section is VS code editor) and click on Attach to Visual Studio Code. This will attach the container to VS code so you can easily make changes via UI.

7. Click on Open Folder on VS Code and select /etc/

8. All the apache/dispatcher configs are located in /etc/httpd/. You can use your project specific configs here (just replace the folders here with your folders)

9. Now, open the /etc/sysconfig/httpd file and modify the ENV variables here. You can use your computer host IP here. So, the Docker container can connect to your local/host server using this IP. For Mac, you can get this from: System Preferences — -> Network — -> Select the network currently you’re connected and it display the IP address.

10. Any time, you make changes to Docker container you’ll have to save them into a new Docker image. Follow the below steps to save changes to a new Docker image:

a. open terminal and type below to get a actively running containers:

docker ps -a

b. Now copy the container id and save this as new image:

docker commit <container id> <image name>

11. Now stop the old container on VS code and start the new image saved in the above step(specific in step 6)

12. Open your host file your computer and add the below entry:

127.0.0.1 www.we-retail.com

13. Now open browser and hit: www.we-retail.com. This call goes to container and container calls back to your host AEM server and renders the we retail page.

Thats it you’ve configured the dispatcher on your local.

Few Things to Remember

  1. All the content is cached under: /mnt/var/www/html
  2. Logs are located under: /etc/httpd/logs/
  3. Any time you make changes to Docker container, you’ll have to save them to a new Docker image and start that image
  4. Apache restart is not possible so you would need to save them the changes to a new image and when you start the image the Apache server gets restarts
  5. If you’re not able to start the container due to some syntax or apache issues, execute the below command to attach the Docker container to a shell:

docker run -it <image name> /bin/bash

6. Once you execute the above command then you can see your container in the VS Code Containers. From there, you can either attach to VS Code or open terminal and fix the apache issues.

7. To share your Docker image with your colleagues or other team members, follow below:

a. docker save -o <tar file path> <docker image name>

b. You can share the above tar file and other devs need to load them using below command:

docker load -i <tar file path>

--

--

No responses yet