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.

Sample:2: Change docker image's tag and registry with annotations

  • This sample runs simple ballerina hello world service in a docker container with annotation configurations to change image name, tag and registry.

  • Following artifacts will be generated from this sample.

    $> docker images
    $> tree
    ├── hello_world_docker.jar
    └── docker
        └── Dockerfile

How to run:

  1. Compile the hello_world_docker.bal file. Command to run docker image will be printed on success:
$> ballerina build hello_world_docker.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
  1. hello_world_docker.jar, Dockerfile and docker image will be generated:
$> tree
├── hello_world_docker.bal
├── hello_world_docker.jar
└── docker
    └── Dockerfile
  1. Verify the docker image is created:
$> docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED              SIZE   v1.0              df83ae43f69b        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
  1. Verify docker container is running:
$> docker ps
CONTAINER ID        IMAGE                            COMMAND                  CREATED                  STATUS              PORTS                    NAMES
130ded2ae413   "/bin/sh -c 'balleri…"   Less than a second ago   Up 3 seconds>9090/tcp   thirsty_hopper
  1. Access the hello world service with curl command:
$> curl -k https://localhost:9090/helloWorld/sayHello
Hello, World!
  1. Remove docker instance and image.
$> docker rm -f 130ded2ae413
$> docker rmi
You can’t perform that action at this time.