JetBrains Space Help

Run Steps in Containers

Short overview:

Selecting a container image

You can use two sources of container images:

  • Docker Hub.

    To use an image from Docker Hub, specify the image name:

    container(image = "hello-world")

    Note that Space caches the images downloaded from Docker Hub. The cache lifetime is no longer than three hours. The disk space required for storing cached images is provided free of charge.

  • Your Space Packages registry.

    To use an image from Space Packages, specify the full image URL:

    container(image = "mycompany.registry.jetbrains.space/p/projectkey/mydocker/hello-world")

What can you run in a container

  • Shell scripts:

    job("Run shell script") { container(displayName = "Show dir contents", image = "ubuntu") { shellScript { interpreter = "/bin/bash" content = """ echo Working dir contents ls /mnt/space/work """ } } }
    Learn more

  • Arbitrary Kotlin code:

    job("Run Kotlin code") { container(displayName = "Say Hello", image = "openjdk:latest") { kotlinScript { api -> println("Hello world!") } } }
    Learn more

  • Container image commands:

    job("Run container command") { container(displayName = "Say Hello", image = "alpine") { args("echo", "Hello World!") } }
    Learn more

Is it possible to run kotlinScript, shellScript, and entrypoint in the same container?

No, it's not possible. The kotlinScript, shellScript, and args | entrypoint items are mutually exclusive. If you specify more than one inside a container, the job will fail.

CorrectWrong
job("Example") { container(image = "openjdk") { kotlinScript { api -> // Do smth. } } container(image = "alpine") { shellScript { content = """ echo Do smth. """ } } }
job("Example") { container(image = "openjdk") { kotlinScript { api -> // Do smth. } shellScript { content = """ echo Do smth. """ } } }

Container resources

A job can contain not more than 50 containers (steps). Each container has the following resources constraints:

DefaultMaxMin
CPU2 virtual CPUs4 virtual CPUs0.2 virtual CPU
Memory7800 MB15600 MB

Note that all containers within a job use the same disk volume (it contains the project repository). The default volume size is 5 GB and the maximum allowed size is 30 GB. To specify resources and volume size, you should use resources and volumeSize correspondingly. Note that all items support units:

  • cpu: You can set a value in .cpu or .mcpu (millicpu), for example, cpu = 250.mcpu is the same as cpu = 0.25.cpu.

  • memory and volumeSize: You can set their values in .mb (MB) and .gb (GB), for example, volumeSize = 10.gb.

job("Example") { // 10 GB volumeSize = 10.gb container(image = "alpine") { resources { // 500.mcpu = 0.5.cpu cpu = 0.5.cpu // 2000 MB memory = 2000.mb } } }
Last modified: 08 June 2021