Skip to content
Branch: master
Find file History

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Sample4: Remote debug ballerina service with docker

  • This sample runs simple ballerina hello world service in a docker container in debug mode.
  • Debug port is default set as 5005. This can be configured with "debugPort: 5005" attribute.
  • Following artifacts will be generated from this sample.
    $> docker images
    $> tree
    ├── hello-world-docker.jar
    └── docker
        └── Dockerfile

How to run:

  1. Compile the docker_debug.bal file. Command to run docker image will be printed on success:
$> ballerina build docker_debug.bal 
Compiling source

Generating executables

Generating docker artifacts...
        @docker                  - complete 2/2 

        Run the following command to start a Docker container:
        docker run -d -p 9090:9090 -p 5005:5005 helloworld-debug:latest

Note that the debug port(5005) is also exposed

  1. docker_debug.jar, Dockerfile and docker image will be generated:
$> tree
├── docker_debug.bal
├── docker_debug.jar
└── docker
    └── Dockerfile
  1. Verify the docker image is created:
$> docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
helloworld-debug     latest              fb9a455e4686        2 minutes ago       102MB
  1. Run docker image as a container (Use the command printed on screen in step 1):
$> docker run -d -p 9090:9090 -p 5005:5005 helloworld-debug:latest
  1. Verify docker container is running:
$> docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                                            NAMES
4c6fbbfe2dac        helloworld-debug:latest   "/bin/sh -c 'balleri…"   1 second ago        Up 8 seconds>5005/tcp,>9090/tcp   condescending_lumiere
  1. Check the docker logs to verify docker image is in debug mode.
$> docker logs -f 4c6fbbfe2dac
ballerina: deploying service(s) in 'docker_debug.jar'
Ballerina remote debugger is activated on port : 5005
  1. Connect to the docker instance from IntelliJ IDEA with ballerina remote debugger.
ip: localhost
port: 5005
  1. Remove docker instance and image.
$> docker rm -f 4c6fbbfe2dac
$> docker rmi helloworld-debug:latest
You can’t perform that action at this time.