---
title: "Creating and using a Docker image stored in an OVHcloud Managed Private Registry"
description: "Find out how to create and use an image stored in an OVHcloud Managed Private Registry."
url: https://docs.ovhcloud.com/fr/guides/public-cloud/containers-orchestration/managed-private-registry/create-private-image
lang: fr
lastUpdated: 2022-04-13
---
# Creating and using a Docker image stored in an OVHcloud Managed Private Registry

## Objective

OVHcloud Managed Private Registry service provides you a managed, authenticated Docker registry where you can privately store your Docker images. This guide will explain how to create a Docker image, store it in the OVHcloud Managed Private Registry service and using it from a Docker client.

## Requirements

- An OVHcloud Managed Private Registry (see the [creating a private registry](/fr/guides/public-cloud/containers-orchestration/managed-private-registry/creation.md) guide for more information)
- An access to the Harbor UI to operate the private registry (see the [connecting to the UI](/fr/guides/public-cloud/containers-orchestration/managed-private-registry/connect-to-ui.md) guide for more information)
- A private project and an user with the right to read and write on the project (see the [managing users and projects](/fr/guides/public-cloud/containers-orchestration/managed-private-registry/managing-users-projects.md) guide for more information)

## Instructions

### Get your OVHcloud Managed Private Registry API URL

Go to your private registry section on the OVHcloud Public Cloud Manager, and in the _more options_ (_..._) button at the right, click on Harbor API.

![API Harbor](/images/public-cloud/containers-orchestration/managed-private-registry/creating-and-using-a-private-image/creating-a-using-a-private-image-001b.png)
Copy the URL of the API Harbor, it's the URL of your private registry and we are going to use it several times in this guide.

![API Harbor](/images/public-cloud/containers-orchestration/managed-private-registry/creating-and-using-a-private-image/creating-a-using-a-private-image-002.png)
> In fact, when you click the copy button as indicated by a hand icon in the image, the copied string starts with `https://`. Please remove the `https://` part.

### Creating a Docker image

You're going to create a Docker image using a very simple Dockerfile and some resource files.

Create a `hello-ovh/` folder and inside create:

- A `Dockerfile` file:

```
FROM nginx:1.15-alpine

COPY index.html /usr/share/nginx/html/index.html
COPY ovh.svg /usr/share/nginx/html/ovh.svg
```

- A `index.html` file:

```
<!doctype html>
<html>
  <head>
    <title>OVHcloud K8S</title>
  </head>
  <body>
    <div class="title">
      <p>Hello from Private Registry!</p>
      <img src="./ovh.svg"/>
    </div>
  </body>
</html>
```

- A `ovh.svg` file (right click and save it):

  (`ovh.svg`)

You should have these files in your `hello-ovh` directory:

```bash
├── Dockerfile
├── index.html
└── ovh.svg
```

- Go into the `hello-ovh` folder, containing the three files, and do a `docker build`. You will need to tag your build using your private registry URL, the project within the registry (_private_ if you followed the [managing users and projects](/fr/guides/public-cloud/containers-orchestration/managed-private-registry/managing-users-projects.md) guide), and the image name (_hello-ovh_):

```bash
docker build --tag [YOUR_PRIVATE_REGISTRY_URL]/[YOUR_PROJECT]/hello-ovh:1.0.0 .
```

Here is the result of running the command for my private registry in the `private` project:

```console
$ docker build --tag 8093ff7x.gra5.container-registry.ovh.net/private/hello-ovh:1.0.0 .
Sending build context to Docker daemon  14.34kB
Step 1/3 : FROM nginx:1.15-alpine
1.15-alpine: Pulling from library/nginx
e7c96db7181b: Pull complete 
264026bbe255: Pull complete 
a71634c55d29: Pull complete 
5595887beb81: Pull complete 
Digest: sha256:57a226fb6ab6823027c0704a9346a890ffb0cacde06bc19bbc234c8720673555
Status: Downloaded newer image for nginx:1.15-alpine
---> dd025cdfe837
Step 2/3 : COPY index.html /usr/share/nginx/html/index.html
---> f1f2487532bc
Step 3/3 : COPY ovh.svg /usr/share/nginx/html/ovh.svg
---> 3f803b45da18
Successfully built 3f803b45da18
Successfully tagged 8093ff7x.gra5.container-registry.ovh.net/private/hello-ovh:1.0.0
```

- Login to your private registry, using a user with write rights to the project (_private-user_ if you followed the [managing users and projects](/fr/guides/public-cloud/containers-orchestration/managed-private-registry/managing-users-projects.md) guide)

```bash
docker login [YOUR_PRIVATE_REGISTRY_URL]
```

In my private registry:

```console
$ docker login 8093ff7x.gra5.container-registry.ovh.net
Username: private-user
Password: 
Login Succeeded
```

- Upload the image to the private registry

```bash
docker push [YOUR_PRIVATE_REGISTRY_URL]/[YOUR_PROJECT]/hello-ovh:1.0.0
```

In my private registry example:

```console
$ docker push 8093ff7x.gra5.container-registry.ovh.net/private/hello-ovh:1.0.0
The push refers to repository [8093ff7x.gra5.container-registry.ovh.net/private/hello-ovh]
369ed87ef8b1: Pushed 
d2220a0eb85b: Pushed 
a521e1bbddf5: Pushed 
bf381a670956: Pushed 
a61993362baf: Pushed 
f1b5933fe4b5: Pushed 
1.0.0: digest: sha256:f5a6a8f0d7c95cf3926b504a7949c8575e478106b59d8913ab947729aa5bd075 size: 1568
```

If you go to your Harbor UI, you will see that a `hello-ovh` repository in the  _private_ project:

![hello-ovh repository](/images/public-cloud/containers-orchestration/managed-private-registry/creating-and-using-a-private-image/creating-a-using-a-private-image-003.png)
This repository will store all the versions of the `hello-ovh` image (right now only the _1.0.0_):

![hello-ovh repository](/images/public-cloud/containers-orchestration/managed-private-registry/creating-and-using-a-private-image/creating-a-using-a-private-image-004.png)
### Deploy the private image

Now you can use `docker pull` (preceded by a `docker login` on your private registry if you're doing it from a different computer) to deploy the image from the OVHcloud Managed Private Registry.

```bash
docker pull [YOUR_PRIVATE_REGISTRY_URL]/[YOUR_PROJECT]/hello-ovh:1.0.0 
```

In my private registry example:

```console
$ docker pull 8093ff7x.gra5.container-registry.ovh.net/private/hello-ovh:1.0.0
1.0.0: Pulling from private/hello-ovh
e7c96db7181b: Already exists 
264026bbe255: Already exists 
a71634c55d29: Already exists 
5595887beb81: Already exists 
4c1b9819c67d: Pull complete 
5df2876c6416: Pull complete 
Digest: sha256:f5a6a8f0d7c95cf3926b504a7949c8575e478106b59d8913ab947729aa5bd075
Status: Downloaded newer image for 8093ff7x.gra5.container-registry.ovh.net/private/hello-ovh:1.0.0
```

And then you can run it:

```bash
docker run -d -p 80:80 [YOUR_PRIVATE_REGISTRY_URL]/[YOUR_PROJECT]/hello-ovh:1.0.0 
```

In my private registry example:

```console
$ docker run -d -p 8080:80 8093ff7x.gra5.container-registry.ovh.net/private/hello-ovh:1.0.0
c18f071c3c8c10ca636ed9be84878c12f3a270b6def131eb756f69435b978da1
```

And now you can test it with the `curl` command:

```bash
$ curl localhost:8080
<!doctype html>

<html>
<head>
<title>OVH K8S</title>
</head>
<body>
<div class="title">
<p>Hello from Private Registry!</p>
<img src="./ovh.svg"/>
</div>
</body>
</html>
```

Or in your browser:

![hello-ovh](/images/public-cloud/containers-orchestration/managed-private-registry/creating-and-using-a-private-image/creating-a-using-a-private-image-005.jpg)
### Go further

To go further you can look at our guide on [Using your private registry with Kubernetes](/fr/guides/public-cloud/containers-orchestration/managed-private-registry/kubernetes.md).
