Bring Your Own Docker Image¶
Besides deployment package ZIP files, we allow for uploading Docker images for your deployments.
Docker images is an experimental feature
Uploading your own Docker images is an experimental feature in UbiOps. Please contact us for access and more information, and for support with deploying your own workloads.
Supporting request format¶
There are two types of deployments that can run in UbiOps: deployments that support request format and that don't. Supporting request format indicates whether a deployment supports requests using the UbiOps deployment request format.
Before uploading a Docker image, it is important to understand what kind of application you want to run. Regular deployments (with a deployment package ZIP file) support requests by default. However, to use this functionality with Bring Your Own Docker Image, your Docker image should be based on a UbiOps deployment image. Please contact our support team to get access to UbiOps deployment images. In case your application doesn't require any UbiOps-format request functionality, and just needs to run as is, e.g. a Jupyter notebook server, WebApp, or API, you can disable support for requests during the deployment and environment creation. See the table below for the differences between two types of deployments.
Functionality | Request format enabled | Request format disabled |
---|---|---|
Version control | ||
Scaling instances | Autoscaling | Manual scaling |
Request creation and queuing | ||
Request retention and traceability | ||
Request schedules | ||
Port forwarding | ||
Static IP |
Preparing the Docker archive¶
Build your Docker image:
docker build --platform linux/amd64 -t my-image -f Dockerfile .
Create an archive from your Docker image:
docker save <image-name> -o image.tar
If your Docker image is a remote image, please pull it first such that you can create an archive from it.
Additional run parameters are not supported (yet)
Passing additional parameters to the docker run
command are not supported (yet). Please, make sure no additional parameters are needed for your Docker image to run. You can do this via the ENTRYPOINT or CMD in your Dockerfile.
Creating the environment¶
First create a new custom environment. This can be done via the WebApp by navigating to Environments > + Custom environment. However, as Docker images are typically big files to upload, doing this via the CLI is the preferred way. The CLI can be installed using pip
:
pip install ubiops-cli
All environment settings can be passed via a YAML file. In the example below, request format is disabled. Change it to true
if your Docker image is built from a UbiOps image, see Supporting request format.
echo "environment_name: my-docker-environment
environment_display_name: My Docker Environment
environment_description: UbiOps Bring Your Own Docker Image tutorial.
environment_supports_request_format: false
environment_labels: {}
gpu_required: false
base_environment: null" > docker_environment.yaml
(echo environment_name: my-docker-environment & echo environment_display_name: My Docker Environment & echo environment_description: UbiOps Bring Your Own Docker Image tutorial. & echo environment_supports_request_format: false & echo environment_labels: {} & echo gpu_required: false & echo base_environment: null) > docker_environment.yaml
environment_name: my-docker-environment
environment_display_name: My Docker Environment
environment_description: UbiOps Bring Your Own Docker Image tutorial.
environment_supports_request_format: false
environment_labels: {}
gpu_required: false
base_environment: null
Create the environment and upload the archive via:
ubiops envs deploy -f docker_environment.yaml -a image.tar
Use the option --overwrite
to upload the archive to an environment that already exists.
Not possible to update the base environment
Keep in mind that it's not possible to change the base environment of an existing environment, and therefore it's also not possible to change the environment type from dependencies in package to a Docker image and vice versa. You will need to create a new environment in that case.
Wait for the environment to be successful via:
ubiops envs wait my-docker-environment
When your environment is successful, you can continue with creating the deployment. Either create a deployment with or without supporting request format.
Create a deployment without supporting request format¶
Create a new deployment by navigating in the WebApp to Deployments > + Create.
- Give a name to your deployment
- Uncheck "Supports request format". All settings that are request related will disappear from the form.
Continue with creating the deployment version.
- In Environment settings, select an instance type from the dropdown. For Bring Your Own Docker, it's only allowed to select a dedicated instance type.
- Then as Environment, select your created Docker environment from the dropdown
- Open the Optional / Additional settings to enable static IP or to set up port forwarding if necessary
- Finally, click Create to create the version
By default, 1 instance will be created for the version. Your Docker image will start running. Navigate to the Active instances tab to see the details of the running instance. Here you can find the IP address of the instance.
Please be aware that there is no autoscaling enabled for deployments that don't support request format. That means that if you don't use the deployment, you need to scale the number of instances to zero yourself, otherwise it will keep running and consume resources. To scale to zero instances, edit the number of instances via the version EDIT button.
Create a deployment with supporting request format¶
Create a new deployment by navigating in the WebApp to Deployments > + Create.
- Give a name to your deployment
- Leave "Supports request format" checked
- See Creating a deployment for more information about the deployment settings
Continue with creating the deployment version.
- Upload your deployment code (ZIP) or skip the upload if the deployment code is already part of the Docker image
- In Environment settings, select an instance type from the dropdown. For Bring Your Own Docker Image, it's only allowed to select a dedicated instance type.
- Then as Environment, select your created Docker environment from the dropdown
- Open the Optional / Additional settings to enable static IP or to set up port forwarding if necessary
- Finally, click Create to create the version