Learn how to containerize your AI Deploy application inside a Docker image to launch successfully.
While our app is running, we will likely have to update our Docker image to correct or bring new features. That is why we will understand in this tutorial how to make our app use the updated version of our Docker image.
Requirements
- Access to the OVHcloud Control Panel
- A Public Cloud project
- A user for AI Deploy
- Docker installed on your local computer or a virtual machine
- The OVHcloud AI CLI
Instructions
Updating our Docker image
When updating a Docker image, we have two options:
- Use an existing tag: This will overwrite the old version of the image with the new one.
- Create a new tag: This will keep the old version of the image while adding the new version.
In this tutorial, we will assume that you already have an app that is running on a Docker image and an updated version of this image. The two previous possibilities (existing tag and new one) will be explained.
Updating our app's image
Updating the image of our application is usually more interesting than restarting a new one. This allows us to keep the same link to the application. We will also avoid having to deploy a new app and specify all our arguments (volumes, ports, resources, etc.) again. Finally, this will allow us to not accumulate our number of deployed apps, resulting in much more efficient management.
Reusing an existing tag
When updating our Docker image, we have reused the same tag as the one specified at the initial launch of our application. We will just have to stop and restart the application to use the new version of our Docker image.
The image tag that was specified at the initial launch of the application will be pulled again during the restart step. Since the initial tag corresponds to the tag of the updated image, the new image version will be pulled and used within our restarted application.
NOTE: As mentioned before, updating your Docker image using the same tag can be dangerous. Keep in mind that this will overwrite and delete your previous version.
Example
Let's imagine that our AI Deploy app was initially launched based on the following image: registry_address.ovh.us/my_ai_app:v1.0.0
. As you can see, our image is stored in the registry_address.ovh.us
registry, is named my_ai_app
, and the version used is tagged v1.0.0
.
Our app is still in a RUNNING
state, which means that it is currently deployed. If we make changes to the image used by this application by pushing our updated image version to the same registry and the same tag, our old image will be replaced by the new version. But as long as our app is running, the deployed image version will not change, which keeps the app running correctly.
However, if we stop and restart the app, the image used will be the one indicated when the app was initially launched, which means the one available at registry_address.ovh.us/my_ai_app:v1.0.0
in our case. As this image has been updated and the old one has been deleted, the last version (updated one) will now be used by the app.
This 'stop and restart' operation can be performed from the OVHcloud Control Panel (UI) by clicking the more options ...
button next to your app, as shown in the screenshot below:
Execute it from the ovhai
CLI with the following commands:
Creating a new tag
On the other hand, if we have updated our image under another tag, we will have to indicate this change to the application. Otherwise, the application will continue to pull the image that was specified when it was first launched.
To indicate the updated version of the image to pull, you can use the ovhai
CLI and enter:
As you can see, you will need to stop and restart the app since the image change only takes effect when the app is restarted.
Example
Let's now imagine that our AI Deploy app was initially launched based on the following image: registry_address.ovh.us/my_ai_app:v1.0.0
. We have updated our image and pushed it on the same registry, but this time with a different tag: registry_address.ovh.us/my_ai_app:v2.0.0
.
If we only stop and restart our app, without specifying the image change (from registry_address.ovh.us/my_ai_app:v1.0.0
to registry_address.ovh.us/my_ai_app:v2.0.0
), the restarted app will continue to use the first image version (registry_address.ovh.us/my_ai_app:v1.0.0
). This means that it will not use the updated version.
To remedy this, we need to stop our application, change the image using the set-image
command, and restart the app so that the change is affected. The deployed app will then use the new version of our Docker image.
Go further
Learn how to use public and private registries when working with OVHcloud AI Tools here.
Discover some AI Deploy apps we built with API or Web frontend via our Apps portfolio.
For more information and tutorials, please see our other AI & Machine Learning support guides or explore the guides for other OVHcloud products and services.
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.