My customer accountSales contactWebmailOVHcloud Blog

Welcome to OVHcloud.

Log in to order, manage your products and services, and track your orders

Log in
OVH Guides

Build & use custom image

Explanations on how to build and use your own custom image

Last updated 8th December, 2020.


This tutorial covers the process of building your own job image for specific needs


Write your own Dockerfile

Create a new file and name it Dockerfile

Choosing a base image

First you need to choose a base image to start from, that base image should have cuda driver installed on to be able to use GPUs when running.

We recommand to choose one from the following lists if you dont want to install cuda drivers yourself.

Here is the list of base images without notebooks that we use :

Here is the list of base images including notebooks (jupyterlab + Visual Studio Code) that we use :

Header of your Dockerfile should look like this :

FROM <base-image>

For example if you want to start from the base image python:1.5.0_gpu_cu101_py3 :

FROM python:1.5.0_gpu_cu101_py3

Install what you need

Bash command instructions on your Dockerfile should begin with RUN prefix.

Example if your want to install vim :

RUN apt-get update && apt-get install -y vim

You can copy files from your local directory inside docker image with the COPY prefix.

Example if you want to add the file example.txt at the root of the image :

COPY example.txt /example.txt

Images in AI Training are not run as root user. It means that if you want to be able to write in a specific directory at runtime you will have to give it specific rights. You can do it with the following instruction :

RUN chown -R 42420:42420 <your-target-directory>

You can set environment variables with the ENV prefix.

Example if you want to add an environment variable KEY with value VALUE


For more information about dockerfile we recommand you to refer to the official documentation

Build image

Once your Dockerfile is complete and match your needs you have to choose a name and build the image using the following command in the same directory :

docker build -t <image-name> .

Test it locally (Optional)

If you want to verify that your built image is working properly, create 2 files :

  • One file named group with following content :
  • One file named passwd with following content :

And run the following command :

docker run --rm -it -v $(pwd)/group:/etc/group -v $(pwd)/passwd:/etc/passwd --user=ovh:ovh <image-name>

Push image in the registry of your choice

Pushing your image to a registry is needed in order for AI Training to pull it.

AI Training provides a default registry called Shared registry where users are able to push their custom images. It is linked with every project by default.

If you prefer using your own private docker registry instead of the shared one, feel free to use it. Just don't forget to attach your registry in your AI Training project before using it.

The basic commands to push a docker image to a registry is :

docker login -u <registry-user> -p <registry-password> <registry>
docker tag <image-name> <registry>/<image-name>
docker push <registry>/<image-name>

Example if you want to push an image named custom-image inside a registry :

docker login -u <registry-user> -p <registry-password>
docker tag custom-image
docker push

If you want to know the exact commands to push on the shared registry, please consult the Details button of the Shared Docker Registry section in the Home panel of AI Training.



Please send us your questions, feedback and suggestions to improve the service:

Did you find this guide useful?

Please feel free to give any suggestions in order to improve this documentation.

Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.

Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.

Thank you. Your feedback has been received.

These guides might also interest you...