How To: create a customized docker image for services


This guide explains how to create a custom docker image starting from the default image provided for some INFN Cloud services.


The user has to be registered in the INFN-Cloud IAM system,, and to have an account on a containers repository to use for uploading the new images.

  • For more details regarding the registration process please see Getting Started.

Download the Dockerfile of the default image provided for a service

Usually the Dockerfiles of images of INFN Cloud services are stored in or repositories. The information regarding the hosting CVS repository can be found in the documentation of the respective INFN Cloud service or can be obtained from the details available on the container registry hosting the respective image. For example:

The Dockerfile is useful to understand how the default image was created and which libraries, tools and environment are already included. Bellow you can see two other example of Dockerfiles, for the NaaS and CYGNO solutions, that can be customised


Figure 1: where the dockerfile of NaaS is stored


Figure 2: where the dockerfile of Cygno is stored

Create a new Dockerfile adding libraries and software

Starting from the image provided for an INFN Cloud service, the user can create a customized one adding libraries, software or custom environment.

It is mandatory to start from the image provided by the service in order to guarantee the correct service operation. The default image will become the “first layer” of the new image.

Here an example on how to write a new Dockerfile starting from the one of the default image provided for an INFN Cloud service

# Start from the default image
FROM <default_image_name>:<version>

# Example for Cygno
# Start from the base image
# FROM dodasts/cygno-lab:<latest_release>

# Example for NaaS
# Start from the base image

# Add env variables
ENV <variable1>=<value>
ENV <variable2>=<value>

# Install additional packages
RUN && yum -y install \
   <packageA> \
   <packageB> \
   && yum -y clean all \
   && rm -f /tmp/packages

# Copy and execute a custom script
COPY <> /tmp/
RUN chmod +x ./tmp/<>
RUN ./tmp/<>

Build the new image and upload it in a repository

When the new Dockerfile is ready, the user can build the related image.

The user must have an account in the docker repository he/she wants to use. It could be for example in Dockerhub, in other providers preferred by the user or, in the very near future, in the INFN Cloud containers registry based on Harbor solution. We are working to make available this service to the INFN Cloud users.

You can see bellow an example of how to upload the new image in the DockerHub registry

  • First the user needs to login using its own credentials:
docker login  ## using repo user credentials (docker_user and password)
  • Then the user has to decide the name and the version of the new image, and build it using the command:
docker build -t <docker_user>/<custom_image>:<version> /<path>/<Dockerfile>/<directory>
  • Finally the new image can be uploaded to the repository
docker push <docker_user>/<custom_image>:<version>

How to use the new image in the service

You can use the new image in the INFN service specifying the <docker_user>/<custom_image>:version as name of the image to use in the configuration form of service.