Hello World with score-compose

Overview

The primary goal of the Score Specification is to quickly and easily describe how to run a Workload. The following covers what you need to know to compose your first score.yaml file and run it with score-compose.

Building blocks

At it’s core, the Score file needs a name and a container to run.

In the following example, the Score tab shows the minimum configuration needed to run a Workload and the Docker Compose tab shows the output of the score-compose run command.

The score.yaml file contains a Workload named hello-world and specifies a container image as busybox.

The following is the minimum configuration needed to run a Workload.

apiVersion: score.dev/v1b1
metadata:
  name: hello-world

containers:
  container-id:
    image: busybox

The output of score-compose run -f ./score.yaml -o ./compose.yaml.

services:
  hello-world:
    image: busybox

Containers

In the following example, we’ll create a simple service based on busybox using the containers definition.

apiVersion: score.dev/v1b1

metadata:
  name: hello-world

containers:
  hello:
    image: busybox
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo Hello World!; sleep 5; done"]

The output of score-compose run -f ./score.yaml -o ./compose.yaml.

services:
  hello-world:
    command:
      - -c
      - while true; do echo Hello World!; sleep 5; done
    entrypoint:
      - /bin/sh
    image: busybox

The following is a description of the previous command.

  • run tells the CLI to translate the Score file to a Docker Compose file.
  • -f is the path to the Score file.
  • -o specifies the path to the output file.

Now, you can run docker compose up to run the Workload as usual.

The following is the output of the previous command.

[+] Running 1/0
⠿ Container score-compose-hello-world-1  Rec... 0.1s
Attaching to score-compose-hello-world-1
score-compose-hello-world-1  | Hello World!

Results You’ve successfully run your first Score Implementation with a Hello World Workload and provisioned it through Docker.