AEM ON DOCKER
In this article we are going to work out on how to install AEM instance on docker container. Less Docker knowledge is required. (all commands with screenshot been attached).
We are setting up 1 author and 1 publishers (2 Containers with Same image) and connect the instances.
1.Ensure latest Docker version up and running.
2.AEM Jar and license file .
3.Docker repository access to pull images. If not please Register in https://hub.docker.com/
My Laptop Configuration :
1.Base OS : Ubuntu with 8 GB RAM.
1.First ensure to start Docker service. In my case I have added in /etc/init.d so Docker get started when I starts my Base OS.
I have not covered some advanced concepts like supervisord , docker compose and Volume binding. Will write article on each in near future.
> service docker start # Start if not added in startup .
Service docker status # confirm Docker status
2.Login to Docker repo and check for the right image . I have tried to get Redhat official images and not able to find any official image. In this we have used FEDORA official verison.
NOTE: Always opt to get official images if you are planning for any Agile platform.
docker pull fedora # docker pull the latest images from Docker repo.
In the above command , docker pulls the latest and save the image. In my case I have already installed and named as fedora/aem . In the below screenshots you would seen as same , ( you need to give the exact image name with tag while you execute)
docker images # Ensure you find your latest downloaded image.
Run the Docker image:
Once you ran Docker image command , Run image to create our container . Images are read only layer and we need to create container to install/ran service on top of image layer.
Docker run -i -t <imagename > /bin/bash I = interactive mode T = tty terminal /bin/bash = Shell to access container .
Check the docker Process from other terminal window .
NOTE : Docker commands will not execute inside containers.
Docker ps # To get to know the status of container.
Install JAVA :
1.In your container , install latest JAVA or move the stable version from Local filesystem to container.
In this case , we install latest java from YUM repository. Since I have the latest it not installed Java for me.
Yum update # Fedora and redhat uses Yum . First update your repository Yum install java-1.8.0-openjdk Yum install java-1.8.0-openjdk-devel
Once java installed , please run Java -version to get whether JAVA installed successfully.
If not running , add the JAVA path to System variables.
For example : If you install java on /opt folder in Container. Execute the below commands
export JAVA_HOME=/opt/jdk1.8.0_171 export JRE_HOME=/opt/jdk1.8.0_171/jre export PATH=$PATH:/opt/jdk1.8.0_171/bin:/opt/jdk1.8.0_171/jre/bin
Mandatory tools to install:
Once Java installed , we need to install few basic tools
Yum install net-tools # Ip commnd will get installed by this command Yum install procps # Ps commnd will get installed by command.
NOTE : Since I have this already installed, so I have skipped it .
Install AEM and License file via Docker cp command:
Dockr cp is used to copy files from Local to Container and Vice versa. This can also be achieved using Docker Volume . Run this command from outside of your container.
Docker cp <SourcePath> <containerID>/<Destinationpath> Cp – Copy command <Sourcepath> : Localfile path with File name <ContainerID> : Container in which you need to transfer it. In our case it is <b9e0cee23ba0> <Destinationpath> : Container path to store the file.
Commit all changes ( Important step)
Docker commit is used to save the changes which you have made . Else all the installation/services been made will be lost.
As I informed earlier Docker command wont work inside container. Open New terminal and type the below command.
Docker commit -m=”comments/modification” <containerID> <User-defined-name> -m = type the changes <containerID> = ID of container <User-defined-name> = User defined name for the New image. Docker images # this command will show your new Image.
Start the New image using Docker Run command.
Docker run -t -i <imagename>:<tagname>
Docker ps # to get the latest container details.
Docker exec -ti <containername> /bin/bash # Login to container and start AEM Process in Background. Once done, please exit the below container . Java process should run in background .
Docker Network :
To run the AEM application , you need to get the IP for this container .
Docker network inspect bridge # We have 3 types of network and will be covered in next article.
We need to grep IPv4Address and type in Browser.
In Browser , type 172.17.0.2:4502/crx/de to start AEM Author.
Docker Network Issue:
If you stop and start the same image again , the IPs would change and due to this reason we need to create own network and assign static Ips to that container.
NOTE : ALL below commands should be executed from your local terminal (not insider container shell )
Docker network create –subnet=<Subnet values> <yournetworkname >
Docker run –net <yournetworkname> --ip <static ip> -it <imagename> /bash
Docker network inspect <yournetworkname>
NOTE: Since I have 2 containers started I can see 2 containers details.
Container 1 : 172.18.0.23
Container 2 : 172.18.0.20
All the IPs can be mapped within subnet range we created.
Inspect your running containers:
If you still need to inspect your container run the below command
Docker container inspect <containerID>
Check for static IP address which is assigned to this container as we have 2 containers.
Start AEM with specified static IP on Browser:
NOTE : Here I am shown steps to install AEM author . Take same image , Start container , change PORT and Hostname in Startup script and exec start command in background.
AEM author screenshot:
AEM Publisher screenshot:
Configure Forward replication and ensure content transfer.
In the below screenshot , added Publisher Ip and make test connection.