Table of Contents
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, https://iam.cloud.infn.it/login, 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.
Usually the Dockerfiles of images of INFN Cloud services are stored in https://baltig.infn.it or https://github.com 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:
- for the “Jupyter with persistence for Notebooks” solution the dodasts/snj-base-lab-persistence:v1.0.3-snj image is related to the https://github.com/DODAS-TS/dodas-docker-images/blob/v1.0.5p1-snj/docker/single-node-jupyterhub/jupyterhub/Dockerfile.
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
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 FROM baltig.infn.it:4567/infn-cloud/jaas_user_containers:base # 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 <script.sh> /tmp/ RUN chmod +x ./tmp/<script.sh> RUN ./tmp/<script.sh>
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>