Lets Get WSO2 Identity Server Configured on AlmaLinux OS.

Have you tried WSO2 Identity Server on AlmaLinux ?

With this Blog post lets see how we can get an AlmaLinux Latest OS configured on top of your primary host machine using a Docker Image and run wso2 Identity Server on top of the configured AlmaLinux OS

Are You new for AlmaLinux ?

Don’t Worry !!! You are few minutes away from setting it up.

AlmaLinux is a free and open source Linux distribution, created originally by CloudLinux to provide a community-supported, production-grade enterprise operating system that is binary-compatible with Red Hat Enterprise Linux. The first stable release of AlmaLinux was published on March 30, 2021.

Is AlmaLinux OS available as a Docker Image ?

Yes, If you are looking for a easy and quick way to get AlmaLinux set up on your current machine the best option is to go with a Docker setup.

So Lets see how we can get AlmaLInux Configured with Docker

How to Configure AlmaLinux OS with Docker Image ?

Prerequisite

You need to have Docker installed in your machine

  1. Refer the AlmaLInux Docker hub page from [1].
  2. Get the Latest AlmaLinux docker image pulled to your machine
docker pull almalinux

2. Run the pulled docker image

docker run -it — name wso2is3 — net=host almalinux:latest

Or else you can expose the necessary ports to the outside without passing — net=host

docker run -it --name wso2is3 almalinux:latest -p 9443:9443 -p 5005:5005

Note

Here when running the docker image you can optionally pass — net=host. Once you pass it the docker container will run on your host machine itself. When you run the docker container in this manner you dont need to access the docker container via a ip address. You can access everything running inside the docker container with localhost without doing any extra configurations. Assume you want to access a sample running in your tomcats localhost by being in the docker container or else you want to debug a test by connecting your host machines intellij idea source code to docker container 5005 port in those cases you can simply do it buy connecting to localhost.

Assume you have a port problem in your host machine where you are using a port for some other service and now you want to run another application on the same port. During such as scenario what you can do is you can execute the docker run command without — net=host. So that docker container will act as a fresh machine with fresh ports. But when running the docker container like this don’t forget to expose the ports to the outside if you have specific ports that you need to access later from your host machine.

docker run -it --name wso2is3 almalinux:latest -p 9443:9443 -p 5005:5005

Now you can access a server running in your docker container using the browser running in your host machine using

https://localhost:9443/carbon/

3. Get the container id of the running docker container

docker ps -a

4. Login to the Almalinux docker container

docker exec -it 743cfc9b8f5f bash

743cfc9b8f5f is the container id

Super !!!!.

Now you have configured the Almalinux OS in your machine as a docker image .

Assume that you didn't pass — net=host when running the docker image and now you want to get the ip address of the docker container which AlmaLinux is running. You can do that using below steps

docker run -it --name wso2is3 almalinux:latest

How to get a Docker Container exposed with a Private IP Address ?

  1. Install net-tools using yum inside the docker image
yum install net-tools

2. Get the Private IP address

hostname -I

Now You can access a server running in docker container by the browser running in your host machine using

https://172.17.0.2:9443/carbon/

How to get Java Configured on AlmaLinux ?

  1. Get oracle JDK 11 downloaded from [2]. You can download it directly to the docker container or download it for your host machine and copy for the container.
  2. Extract the downloaded file using below command if its a tzr.gz file
tar xzf jdk-11.0.13_linux-x64_bin.tar.gz

3. Now navigate to /home/etc using

cd /home/etc

4. Open the bashrc file

vi bashrc

5. Configure java home as below

export JAVA_HOME=/home/shanika/jdk11.0.3export PATH=”$JAVA_HOME/bin:$PATH”

6. Update and save the bashrc file

. ~/.bashrc

After everything is done. Close all the terminals running in your machine with AlmaLinux Docker container. and Reopen a new terminal and access the docker container and check the java version from below command.

java -version

This should show your java home with jdk 11 path

This is required to do because if you dont configure java as a systmem configuration in your bashrc file then once you terminate the terminal it might take other java versions like (openjdk) if multiple java types are running in your container.

How to Copy a File from your Host Machine to the Docker container

You can use below command for this

docker cp wso2is-5.11.0.zip 743cfc9b8f5f:/home/shanika/product-is/modules/distribution/target

Here 743cfc9b8f5f is the containerid. and /home/shanika/product-is/modules/distribution/target is the path where you want the file to be copied inside the container. wso2is-5.11.0.zip is the file path of the file that will be copied from the host machine.

How to Copy a File from your Docker container to the Host Machine

You can use below command for this

docker cp 743cfc9b8f5f:/home/shanika/packbuiltfromrepocopy/wso2is-5.11.0/repository/logs/wso2carbon.log /home/shanika/WSO2/almalinux

Here 743cfc9b8f5f is the containerid. and /home/shanika/packbuiltfromrepocopy/wso2is-5.11.0/repository/logs/wso2carbon.log is the file that needs to be copied. /home/shanika/WSO2/almalinux is the destination where you want the file to be copied.

Useful Commands when working with AlmaLinux

Install Git

yum install git

Install Maven

yum install mavenmvn -version

How To run WSO2 Identity Server on AlmaLinux

You are almost done with configuring Alma Linux OS and Java. Now you can get the IS pack and get it copy inside the docker container.

Prerequisite

Alma Linux OS configured with Docker

Java configured and JAVA-HOME set correctly

  1. Unzip the pack
yum install unzip
unzip wso2-is-5.11.0zip

2. Navigate <IS-HOME>/bin

3. Run sh wso2server.sh

sh wso2server.sh

4. Now you can access the server with either one of the commands

https://localhost:9443/carbon > If — net=host is passed as mentioned above

https://172.17.0.2:9443/carbon > If — net=host is not passed and a private ip is exposed as mentioned above

5. You can shut down the server by being in the same directory and typing ctrl+c or grep for the below port and kill the port

ps -ef | grep wso2kill -9 port

Yaay !!! Now you are done with all the configurations needed. Lets Use WSO2 Identity Server on top of AlmaLinux.

[1]. https://hub.docker.com/_/almalinux

[2]. https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html

[3]. https://wso2.com/identity-server/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shanika Wickramasinghe

Shanika Wickramasinghe

Senior Software Engineer and Freelance Technical Writer. I write about any Computer Science related topic. https://www.linkedin.com/in/shanikawickramasinghe