Installing Coco in Docker

In this chapter we give an example on how to run Coco, terminal only interaction, in Docker.


  1. A Linux machine, in this example Debian,
  2. Docker (latest version, but any stable version should work fine).

Installation of Docker

Before installing Coco we need Docker to be installed. To check if Docker is running on your machine, type:

$ docker --version

Skip the following step if Docker is already installed on your machine.

Installation from the Debian repository

A standard Debian distribution contains already a Docker package. It is usually called docker or To install it, run:

$ sudo apt-get install

Installation from the Docker repository

If you need the newest version of Docker, you can use the Docker repository instead. The following procedure to install Docker is mostly the same for all Linux based machines. For more information, see the Docker documentation.

  1. Update the apt package index:
    $ sudo apt-get update
  2. Install packages to allow apt to use a repository over HTTPS:
    $ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
  3. Add Docker's official GPG key:
    $ curl -fsSL | sudo apt-key add -
  4. Use the following command to set up the stable repository:
    $ sudo add-apt-respostiory \
            "deb [arch=amd64] \
            $(lsb_release -cs) \
  5. Update the apt package index:
    $ sudo apt-get update
  6. Install the latest version of Docker CE and containerd:
    $ sudo apt-get install docker-ce docker-ce-cli

Verification of the installation

Now verify that your user account has the right to run Docker containers. On most UNIX® systems, a user must be in the docker group. To verify this, use the id command, which prints the current groups a user is in. If you are not a member of docker, run:

$ sudo adduser <own accout> docker

But afterwards it is usually necessary to log in again in order to make the group change visible.

To verify that Docker CE is installed correctly, run the hello-world image:

$ docker run hello-world

To remove the hello-world image, first run:

$ docker ps -a

The output should be a list of containers, with name, status, and more. It should contain one header line and one line for the hello-world image. In the first column, there is the container ID of the hello-world image. Run:

$ docker rm <container_id>

Installation of Coco in a Docker container

  1. Create an empty directory. We will refer to it as work directory.
  2. Download a Coco package to the work directory. It must be a file that ends in .run, like
  3. In the work directory, create a file named Dockerfile, with the following content:
    # Select base image
    FROM debian
    # Install packages for your project
    RUN apt-get update && apt-get upgrade -y && apt-get install -y libgtk2.0-dev
    # Set "secret" as root password
    RUN echo "root:secret" | chpasswd
    # Define a user
    RUN useradd -ms /bin/bash myapp
    USER myapp
    WORKDIR /home/myapp
    # Copy the Coco installer to the work directory
    COPY SquishCocoSetup*.run .

    For an actual project, the content of the file must be adapted. In this example, it does the following:

    1. Loads an image from the Docker Hub website. In this case it is the most recent Debian image, but any Linux image should work.
    2. Installs some packages. In a real use case, these would be the prerequisites of the software project for which code coverage should be measured.

      The installation commands that are given here obviously only work on a Debian or Debian-like system, like Ubuntu.

    3. Sets a root password that is later needed by the Coco installer, which runs from a user account.
    4. Creates a user account.
    5. Copies the Coco installer into the container. It will be located in the home directory of the user myapp.

      The wildcard pattern SquishCocoSetup*.run matches the name of any Coco installer package, independent of the version number.

  4. In the work directory, run the command:
    $ docker build -t squishcoco .

    Docker will then create an image with the name squishcoco.

  5. To run the image, execute the command:
    $ docker run -it --name runner squishcoco

    Then a container named runner will be created and started.

  6. You will now see the command prompt of the container, no longer that of your operating system. You are now in the home directory of the user myapp.

    This directory also contains a copy of the Coco installer package. You can run it with a command like:

    myapp@a6e8af:~$ bash

    The installer will then let you choose between different installation modes. Choose the first, Installation on a the local machine. The installer will then ask for the root password, which is of course secret.

    At the end of the installation, the installer asks, Do you want to start \COCO License Manager in order to register this product?. Answer no because the installer uses a graphical interface, which is usually not possible in a Docker container.

  7. Instead, the non-GUI version of the license manager must be used. Run one of the following commands:
    • If you got an activation code, make sure that the Docker container has internet access enabled, then run:

      myapp@a6e8af:~$/opt/SquishCoco/bin/cocolic --fetch-license-key=<activation code>

      The license key will then be fetched from the license server. Afterwards, the internet access can be disabled again.

    • If you have got a license key, run:

      myapp@a6e8af:~$/opt/SquishCoco/bin/cocolic --license-key=<license key>

    • If you use a license server, run:

      myapp@a6e8af:~$/opt/SquishCoco/bin/cocolic --license-server=<server>:<port>

      In this case, the Docker container needs to have network access enabled during compilation and whenever a Coco tool runs. When the instrumented program runs, no network access is needed.

    If an error message is displayed, contact froglogic support.

    Alternatively, you can check if the license is activated or not by running the command below:

    myapp@a6e8af:~$/opt/SquishCoco/bin/cocolic --check

  8. Now Coco is installed in Docker. You can exit the container with the exit command.
  9. To enter the container again, run:
    $ docker start -ai runner