NavigationContentFooter
Suggest an edit

How to create and deploy a container with the Scaleway API

Reviewed on 28 August 2024Published on 18 August 2021

The Scaleway API allows you to create and manage all your Scaleway resources programmatically. Anything you can do through the Scaleway console can also be done through the API.

Refer to the Scaleway Developers website for more information on the Scaleway API.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • A valid API key
  • Installed curl
  • Made your first request using the Scaleway API
  1. Run the following command in your terminal to create a containers namespace:

    curl -X POST \
    -H "X-Auth-Token: $SCW_SECRET_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "name": "<YOUR_NAMESPACE_NAME>",
    "project_id": "YOUR_PROJECT_ID"
    }' \
    "https://api.scaleway.com/containers/v1beta1/regions/fr-par/namespaces"

    An output similar to the following displays:

    {"id":"example-fb93-43e3-a036-7be69f1af7a1", "name":"your-namespace-name", "environment_variables":{}, "organization_id":"example-776f-4f65-a41e-6c5fc58b4076", "project_id":"example-c162-43f7-bb3e-1182e6f12342", "status":"pending", "registry_namespace_id":"", "error_message":null, "registry_endpoint":"", "description":"", "secret_environment_variables":[], "region":"fr-par"}%
  2. Run the following command to create a container:

    curl -X POST \
    -H "X-Auth-Token: $SCW_SECRET_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "name": "<YOUR_CONTAINER_NAME>",
    "namespace_id": "<YOUR_NAMESPACE_ID>",
    "runtime": "<RUNTIME>"
    }' \
    "https://api.scaleway.com/containers/v1beta1/regions/fr-par/containers"

    An output similar to the following displays:

    {"id":"ef777a64-1f4e-4d43-8227-26927c7de057", "name":"your-container-name", "namespace_id":"example-fb93-43e3-a036-7be69f1af7a1", "status":"created", "environment_variables":{}, "min_scale":0, "max_scale":5, "runtime":"python310", "memory_limit":256, "cpu_limit":140, "timeout":"300s", "handler":"handler.handle", "error_message":null, "privacy":"public", "description":"", "domain_name":"namespaceg04rnwx-container-example.containers.cnt.fr-par.scw.cloud", "secret_environment_variables":[], "http_option":"enabled", "runtime_message":"", "build_message":null, "region":"fr-par"}%
    Note

    For testing purposes, you can use the "registry_image": "nginx:latest" and "port": "80" parameters to quickly create a container.

  3. Run the following command to deploy your container:

    curl -X POST \
    -H "X-Auth-Token: $SCW_SECRET_KEY" \
    -H "Content-Type: application/json" \
    -d '{}' \
    "https://api.scaleway.com/containers/v1beta1/regions/fr-par/containers/<YOUR_CONTAINER_ID>/deploy"

    The deployment process can take several minutes, depending on the image used.

  4. Run the following command to call your container once it is deployed:

    curl <YOUR_CONTAINER_ENDPOINT>

    Your container is now deployed and ready to use.

API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2024 – Scaleway