Now, with the use of dockers we can set up a cluster within few seconds and it makes your life easy :)
So let me give a basic knowledge on what is "docker"
What is Docker
In most simplest terms, docker is a platform to containerize software images.
Install Docker : https://docs.docker.com/engine/installation/linux/ubuntulinux/
What is Docker Compose
Docker compose is used to compose several applications and run those using one single command to initialize in multiple containers.
Install Docker Compose : https://docs.docker.com/compose/install/
For some of the wso2 products there are docker compose images already exists in a private repository.
Main purpose of this blog is to highlight some of the useful docker commands you have to use while working with docker compose images.
To explain some of the usages I will be using ESB 4.9.0 docker compose image.
You can get a clone of the git repository where the docker compose image for ESB 4.9.0 is available. Follow the instructions in the READ.ME to setup the ESB docker cluster.
Start Docker container
Build the changes and up the docker compose image
docker-compose up --build
Stop docker containers
Start docker in demon mode
Docker-compose up -d
List docker images
List running docker containers
Login to an active container
docker exec -i -t <container_id> /bin/bash
Delete/Kill existing containers
docker rm -f $(docker ps -aq)
View container logs
docker logs <container_id>
Insert a delay between docker containersSample Scenario: When running ESB cluster, first we want to ensure that DB is up and running, Therefore we can introduce a delay and start the ESB nodes. To configure this, you can add below property to the docker-compose.yml file
environment: - SLEEP=50
Add additional host namesSample Scenario: Lets assume you want to use a backend service hosted in Application Server in another instance. Host name of the Application Server is "as.wso2.org". Docker can not resolve the host name unless you defined the host name in docker-compose.yml file as below.
extra_hosts: - "as.wso2.org:192.168.48.131"
Enable additional portsSample Scenario: Each of the ports used for the docker compose should be exposed through the docker-compose.yml file. If you are using inbound HTTP endpoint with port 7373, this port should be exposed as below.
ports: - "443:443" - "80:80" - "7373:7373"