Deploy an Azure API Management self-hosted gateway to Docker

Availability

Important

This feature is available in the Premium and Developer tiers of API Management.

This article provides the steps for deploying self-hosted gateway component of Azure API Management to a Docker environment.

Important

Support for Azure API Management self-hosted gateway version 0 and version 1 container images is ending on 1 October 2023, along with its corresponding Configuration API v1. Use our migration guide to use self-hosted gateway v2.0.0 or higher with Configuration API v2. Learn more in our deprecation documentation

Note

Hosting self-hosted gateway in Docker is best suited for evaluation and development use cases. Kubernetes is recommended for production use. Learn how to deploy with Helm or using deployment YAML file to learn how to deploy self-hosted gateway to Kubernetes.

Prerequisites

Note

Self-hosted gateway is packaged as a x86-64 Linux-based Docker container.

Deploy the self-hosted gateway to Docker

  1. Select Gateways from under Deployment and infrastructure.

  2. Select the gateway resource you intend to deploy.

  3. Select Deployment.

  4. Note that an access token in the Token text box was autogenerated for you using the default Expiry and Secret key values. If needed, pick desired values in either or both controls to generate a new token.

  5. Make sure Docker is selected under Deployment scripts.

  6. Select env.conf file link next to the Environment to download the file.

  7. Select copy icon located at the right end of the Run text box to copy the Docker command to clipboard.

  8. Paste the command to the terminal (or command) window. Adjust the port mappings and container name as needed. Note that the command assumes that downloaded environment file is present in the current directory.

    docker run -d -p 80:8080 -p 443:8081 --name <gateway-name> --env-file env.conf mcr.microsoft.com/azure-api-management/gateway:<tag>
    
  9. Execute the command. The command instructs your Docker environment to run the container using a container image from the Microsoft Artifact Registry, and to map the container's HTTP (8080) and HTTPS (8081) ports to ports 80 and 443 on the host.

  10. Run the below command to check if the gateway container is running:

    docker ps
    CONTAINER ID        IMAGE                                                 COMMAND                  CREATED             STATUS              PORTS                                         NAMES
    895ef0ecf13b        mcr.microsoft.com/azure-api-management/gateway:latest   "/bin/sh -c 'dotnet …"   5 seconds ago       Up 3 seconds        0.0.0.0:80->8080/tcp, 0.0.0.0:443->8081/tcp   my-gateway
    
  11. Go back to Azure portal, click on Overview and confirm that self-hosted gateway container you just deployed is reporting a healthy status.

    gateway status

Tip

Use console docker container logs <gateway-name> command to view a snapshot of self-hosted gateway log.

Use docker container logs --help command to see all log viewing options.

Next steps