This post contains how to debug a docker container. As per the prerequisites, users have to clone two WSO2 repos along the road. Other than that he or she should have good knowledge in remote debugging. Without further due let's start the process.
First clone and download the Puppet modules for WSO2 products.
https://github.com/wso2/puppet-modules.git
Move to the v2.1.0 tag
Add the product pack and JDK to following locations.
Download and copy JDK 1.7 (jdk-7u80-linux-x64.tar.gz) pack to below directory.
<PUPPET_HOME>/modules/wso2base/files
Download the relevant product pack and copy them to below directory.
<PUPPET_HOME>/modules/wso2greg/files
Then clone WSO2 Dockerfiles
https://github.com/wso2/dockerfiles.git
Now set puppet home using below terminal command.
export PUPPET_HOME=<puppet_modules_path>
Example:
export PUPPET_HOME=/Users/thushara/Documents/greg/wso2/puppet-modules
Update the following lines in entrypoint.sh
<dockerfiles_home>/common/scripts/entrypoint.sh
Example:
echo "Starting ${SERVER_NAME} with [Startup Args] ${STARTUP_ARGS}, [CARBON_HOME] ${CARBON_HOME}"
${CARBON_HOME}/bin/wso2server.sh start
sleep 10s
tail -500f ${CARBON_HOME}/repository/logs/wso2carbon.log
Lets install Vim in the docker container for debugging purposes. For that add following lines to Dockerfile, before last 2 lines.
<dockerfiles_home>/wso2greg/Dockerfile
RUN apt-get install -y vim
${CARBON_HOME}/bin/wso2server.sh start
sleep 10s
tail -500f ${CARBON_HOME}/repository/logs/wso2carbon.log
Lets install Vim in the docker container for debugging purposes. For that add following lines to Dockerfile, before last 2 lines.
<dockerfiles_home>/wso2greg/Dockerfile
RUN apt-get install -y vim
Now update the following line to open remote debug ports.
<dockerfiles_home>/wso2greg/run.sh
Example:
bash ${common_folder}/docker-run.sh -n ${product_name} -p 9763:9763 -p 9443:9443 -p 5005:5005 $*
Thats it with the configuration now you can build and start docker container to start debugging.
First build the docker container,
<dockerfiles_home>/wso2greg $ bash build.sh -v 5.2.0 -r puppet
Now run the docker container,
<dockerfiles_home>/wso2greg $ bash run.sh -v 5.2.0
To find the docker container name please list all the docker processes running using below command,
<dockerfiles_home>/wso2greg $ docker ps
Let's login to the docker instance using image name(wso2greg-default) which we got using docker ps command.
<dockerfiles_home>/wso2greg $ docker exec -it wso2greg-default /bin/bash
Now you can start remote debugging as you use to it :)
Below I have added additional commands you might need. To see the list of docker machines up and running use below commands,
<dockerfiles_home>/wso2greg $ docker-machine ls
That's it from here. If you have any questions please create a StackOverflow question and attached it as a comment below.
i just go through your article it was very interesting time just pass away by reading your article looking for more updates. Thank you for sharing
ReplyDeleteDocker Training in Hyderabad
Kubernetes Training in Hyderabad
Docker and Kubernetes Training
Docker and Kubernetes Online Training
Hey there! I could have sworn I've been to this blog before but after browsing through some of the post I realized it's new to me. Anyways, I'm definitely happy I found it and I'll be bookmarking and checking back frequently! shipping container sizes and prices
ReplyDelete