11/23/2021»»Tuesday

Install Curl Docker Container

-->
  1. Install Curl during Docker Image Build Process and better understand the build process 28th September 2021 curl, docker, docker-for-windows, dockerfile, vb.net This is a linked question to my previous question RUN cmd and execute curl command in VB.NET.
  2. I created a docker container from my OS X VM Docker host. I created it using the run command and created the container based off the ubuntu:xenial image off docker hub. I'm now connected to my container after it's created and logged in as root and at the command prompt inside my container.

Containers enable you to run the Text Analytic APIs in your own environment and are great for your specific security and data governance requirements. The following Text Analytics containers are available:

Nov 19, 2019 Docker Compose is a tool used to define and run multi-container Docker applications. Users utilize this software to launch, execute, communicate, and close containers with a single coordinated command. This tutorial will show you how to install Docker Compose on CentOS 7.

  • sentiment analysis
  • language detection
  • key phrase extraction (preview)
  • Text Analytics for health

Note

  • Entity linking and NER are not currently available as a container.
  • The container image locations may have recently changed. Read this article to see the updated location for this container.
  • The free account is limited to 5,000 text records per month and only the Free and Standardpricing tiers are valid for containers. For more information on transaction request rates, see Data Limits.

Containers enable you to run the Text Analytic APIs in your own environment and are great for your specific security and data governance requirements. The Text Analytics containers provide advanced natural language processing over raw text, and include three main functions: sentiment analysis, key phrase extraction, and language detection.

Container

If you don't have an Azure subscription, create a free account before you begin.

Prerequisites

You must meet the following prerequisites before using Text Analytics containers. If you don't have an Azure subscription, create a free account before you begin.

  • Docker installed on a host computer. Docker must be configured to allow the containers to connect with and send billing data to Azure.
    • On Windows, Docker must also be configured to support Linux containers.
    • You should have a basic understanding of Docker concepts.
  • A Text Analytics resource with the free (F0) or standard (S) pricing tier.

Gathering required parameters

There are three primary parameters for all Cognitive Services' containers that are required. The end-user license agreement (EULA) must be present with a value of accept. Additionally, both an Endpoint URL and API Key are needed.

Endpoint URI {ENDPOINT_URI}

The Endpoint URI value is available on the Azure portal Overview page of the corresponding Cognitive Service resource. Navigate to the Overview page, hover over the Endpoint, and a Copy to clipboard icon will appear. Copy and use where needed.

Keys {API_KEY}

This key is used to start the container, and is available on the Azure portal's Keys page of the corresponding Cognitive Service resource. Navigate to the Keys page, and click on the Copy to clipboard icon.

Important

These subscription keys are used to access your Cognitive Service API. Do not share your keys. Store them securely, for example, using Azure Key Vault. We also recommend regenerating these keys regularly. Only one key is necessary to make an API call. When regenerating the first key, you can use the second key for continued access to the service.

Host computer requirements and recommendations

The host is a x64-based computer that runs the Docker container. It can be a computer on your premises or a Docker hosting service in Azure, such as:

  • Azure Kubernetes Service.
  • Azure Container Instances.
  • A Kubernetes cluster deployed to Azure Stack. For more information, see Deploy Kubernetes to Azure Stack.

The following table describes the minimum and recommended specifications for the available Text Analytics containers. Each CPU core must be at least 2.6 gigahertz (GHz) or faster. The allowable Transactions Per Second (TPS) are also listed.

Install Curl Docker Container Tracking

Minimum host specsRecommended host specsMinimum TPSMaximum TPS
Language detection1 core, 2GB memory1 core, 4GB memory1530
key phrase extraction (preview)1 core, 2GB memory1 core, 4GB memory1530
Sentiment Analysis1 core, 2GB memory4 cores, 8GB memory1530
Text Analytics for health - 1 document/request4 core, 10GB memory6 core, 12GB memory1530
Text Analytics for health - 10 documents/request6 core, 16GB memory8 core, 20GB memory1530

CPU core and memory correspond to the --cpus and --memory settings, which are used as part of the docker run command.

Docker Container Install Curl

Get the container image with docker pull

Docker pull for the Sentiment Analysis v3 container

The sentiment analysis container v3 container is available in several languages. To download the container for the English container, use the command below.

To download the container for another language, replace en with one of the language codes below.

Text Analytics ContainerLanguage code
Chinese-Simplifiedzh-hans
Chinese-Traditionalzh-hant
Dutchnl
Englishen
Frenchfr
Germande
Hindihi
Italianit
Japaneseja
Koreanko
Norwegian (Bokmål)no
Portuguese (Brazil)pt-BR
Portuguese (Portugal)pt-PT
Spanishes
Turkishtr

For a full description of available tags for the Text Analytics containers, see Docker Hub.

Docker pull for the Key Phrase Extraction container

Use the docker pull command to download a container image from Microsoft Container Registry.

For a full description of available tags for the Text Analytics containers, see the Key Phrase Extraction container on the Docker Hub.

Docker pull for the Language Detection container

Use the docker pull command to download a container image from Microsoft Container Registry.

For a full description of available tags for the Text Analytics containers, see the Language Detection container on the Docker Hub.

Use the docker pull command to download this container image from the Microsoft public container registry.

Tip

You can use the docker images command to list your downloaded container images. For example, the following command lists the ID, repository, and tag of each downloaded container image, formatted as a table:

Run the container with docker run

Once the container is on the host computer, use the docker run command to run the containers. The container will continue to run until you stop it.

Important

  • The docker commands in the following sections use the back slash, , as a line continuation character. Replace or remove this based on your host operating system's requirements.
  • The Eula, Billing, and ApiKey options must be specified to run the container; otherwise, the container won't start. For more information, see Billing.
    • If you're using the Text Analytics for health container, the responsible AI (RAI) acknowledgment must also be present with a value of accept.
  • The sentiment analysis and language detection containers use v3 of the API, and are generally available. The key phrase extraction container uses v2 of the API, and is in preview.

To run the Sentiment Analysis v3 container, execute the following docker run command. Replace the placeholders below with your own values:

PlaceholderValueFormat or example
{LANGUAGE}The language of the container you want to run. Make sure this matches the docker pull command you used. Note the hyphen (-) used before the language in the example below.en
{API_KEY}The key for your Text Analytics resource. You can find it on your resource's Key and endpoint page, on the Azure portal.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI}The endpoint for accessing the Text Analytics API. You can find it on your resource's Key and endpoint page, on the Azure portal.https://<your-custom-subdomain>.cognitiveservices.azure.com

This command:

  • Runs a Sentiment Analysis container from the container image
  • Allocates one CPU core and 8 gigabytes (GB) of memory
  • Exposes TCP port 5000 and allocates a pseudo-TTY for the container
  • Automatically removes the container after it exits. The container image is still available on the host computer.

To run the Key Phrase Extraction container, execute the following docker run command. Replace the placeholders below with your own values:

PlaceholderValueFormat or example
{API_KEY}The key for your Text Analytics resource. You can find it on your resource's Key and endpoint page, on the Azure portal.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI}The endpoint for accessing the Text Analytics API. You can find it on your resource's Key and endpoint page, on the Azure portal.https://<your-custom-subdomain>.cognitiveservices.azure.com

This command:

  • Runs a Key Phrase Extraction container from the container image
  • Allocates one CPU core and 4 gigabytes (GB) of memory
  • Exposes TCP port 5000 and allocates a pseudo-TTY for the container
  • Automatically removes the container after it exits. The container image is still available on the host computer.

To run the Language Detection container, execute the following docker run command. Replace the placeholders below with your own values:

PlaceholderValueFormat or example
{API_KEY}The key for your Text Analytics resource. You can find it on your resource's Key and endpoint page, on the Azure portal.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI}The endpoint for accessing the Text Analytics API. You can find it on your resource's Key and endpoint page, on the Azure portal.https://<your-custom-subdomain>.cognitiveservices.azure.com

This command:

  • Runs a Language Detection container from the container image
  • Allocates one CPU core and 4 gigabytes (GB) of memory
  • Exposes TCP port 5000 and allocates a pseudo-TTY for the container
  • Automatically removes the container after it exits. The container image is still available on the host computer.

Install the container

There are multiple ways you can install and run the Text Analytics for health container.

  • Use the Azure portal to create a Text Analytics resource, and use Docker to get your container.
  • Use an Azure VM with Docker to run the container. Refer to Docker on Azure.
  • Use the following PowerShell and Azure CLI scripts to automate resource deployment and container configuration.

Docker Container Virtualization

Run the container locally

To run the container in your own environment after downloading the container image, execute the following docker run command. Replace the placeholders below with your own values:

Container
PlaceholderValueFormat or example
{API_KEY}The key for your Text Analytics resource. You can find it on your resource's Key and endpoint page, on the Azure portal.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI}The endpoint for accessing the Text Analytics API. You can find it on your resource's Key and endpoint page, on the Azure portal.https://<your-custom-subdomain>.cognitiveservices.azure.com

This command:

  • Runs the Text Analytics for health container from the container image
  • Allocates 6 CPU core and 12 gigabytes (GB) of memory
  • Exposes TCP port 5000 and allocates a pseudo-TTY for the container
  • Accepts the end user license agreement (Eula) and responsible AI (RAI) terms
  • Automatically removes the container after it exits. The container image is still available on the host computer.

Run the container with Client library support

Starting with container version 3.0.017010001-onprem-amd64 (or if you use the latest container), you can run the Text Analytics for health container to work with the Text Analytics client library health operation. To do so, add the following parameter to the docker run command:

enablelro=true

Afterwards when you authenticate the Text Analytics client, use the endpoint that your container is running on:

http://localhost:5000

For example, if you're using C# you would use the following code:

Container

Demo UI to visualize output

Note

The demo is only available with the Text Analytics for health container.

The container provides REST-based query prediction endpoint APIs. We have also provided a visualization tool in the container that is accessible by appending /demo to the endpoint of the container. For example:

Use the example cURL request below to submit a query to the container you have deployed replacing the serverURL variable with the appropriate value.

Install the container using Azure Web App for Containers

Azure Web App for Containers is an Azure resource dedicated to running containers in the cloud. It brings out-of-the-box capabilities such as autoscaling, support of docker containers and docker compose, HTTPS support and much more.

Note

Using Azure Web App you will automatically get a domain in the form of <appservice_name>.azurewebsites.net

Run this PowerShell script using the Azure CLI to create a Web App for Containers, using your subscription and the container image over HTTPS. Wait for the script to complete (approximately 25-30 minutes) before submitting the first request.

Install the container using Azure Container Instance

You can also use an Azure Container Instance (ACI) to make deployment easier. ACI is a resource that allows you to run Docker containers on-demand in a managed, serverless Azure environment.

See How to use Azure Container Instances for steps on deploying an ACI resource using the Azure portal. You can also use the below PowerShell script using Azure CLI, which will create a ACI on your subscription using the container image. Wait for the script to complete (approximately 25-30 minutes) before submitting the first request. Due to the limit on the maximum number of CPUs per ACI resource, do not select this option if you expect to submit more than 5 large documents (approximately 5000 characters each) per request.See the ACI regional support article for availability information.

Note

Azure Container Instances don't include HTTPS support for the builtin domains. If you need HTTPS, you will need to manually configure it, including creating a certificate and registering a domain. You can find instructions to do this with NGINX below.

Secure ACI connectivity

By default there is no security provided when using ACI with container API. This is because typically containers will run as part of a pod which is protected from the outside by a network bridge. You can however modify a container with a front-facing component, keeping the container endpoint private. The following examples use NGINX as an ingress gateway to support HTTPS/SSL and client-certificate authentication.

Note

NGINX is an open-source, high-performance HTTP server and proxy. An NGINX container can be used to terminate a TLS connection for a single container. More complex NGINX ingress-based TLS termination solutions are also possible.

Set up NGINX as an ingress gateway

NGINX uses configuration files to enable features at runtime. In order to enable TLS termination for another service, you must specify an SSL certificate to terminate the TLS connection and proxy_pass to specify an address for the service. A sample is provided below.

Note

ssl_certificate expects a path to be specified within the NGINX container's local filesystem. The address specified for proxy_pass must be available from within the NGINX container's network.

The NGINX container will load all of the files in the _.conf_ that are mounted under /etc/nginx/conf.d/ into the HTTP configuration path.

Example Docker compose file

The below example shows how a docker compose file can be created to deploy the NGINX and Text Analytics for health containers:

To initiate this Docker compose file, execute the following command from a console at the root level of the file:

For more information, see NGINX's documentation on NGINX SSL Termination.

Run multiple containers on the same host

If you intend to run multiple containers with exposed ports, make sure to run each container with a different exposed port. For example, run the first container on port 5000 and the second container on port 5001.

You can have this container and a different Azure Cognitive Services container running on the HOST together. You also can have multiple containers of the same Cognitive Services container running.

Query the container's prediction endpoint

The container provides REST-based query prediction endpoint APIs.

Use the host, http://localhost:5000, for container APIs.

Validate that a container is running

There are several ways to validate that the container is running. Locate the External IP address and exposed port of the container in question, and open your favorite web browser. Use the various request URLs below to validate the container is running. The example request URLs listed below are http://localhost:5000, but your specific container may vary. Keep in mind that you're to rely on your container's External IP address and exposed port.

Install Curl Docker Container Store

Request URLPurpose
http://localhost:5000/The container provides a home page.
http://localhost:5000/readyRequested with GET, this provides a verification that the container is ready to accept a query against the model. This request can be used for Kubernetes liveness and readiness probes.
http://localhost:5000/statusAlso requested with GET, this verifies if the api-key used to start the container is valid without causing an endpoint query. This request can be used for Kubernetes liveness and readiness probes.
http://localhost:5000/swaggerThe container provides a full set of documentation for the endpoints and a Try it out feature. With this feature, you can enter your settings into a web-based HTML form and make the query without having to write any code. After the query returns, an example CURL command is provided to demonstrate the HTTP headers and body format that's required.

Stop the container

To shut down the container, in the command-line environment where the container is running, select Ctrl+C.

Troubleshooting

If you run the container with an output mount and logging enabled, the container generates log files that are helpful to troubleshoot issues that happen while starting or running the container.

Tip

For more troubleshooting information and guidance, see Cognitive Services containers frequently asked questions (FAQ).

Billing

The Text Analytics containers send billing information to Azure, using a Text Analytics resource on your Azure account.

Queries to the container are billed at the pricing tier of the Azure resource that's used for the ApiKey.

Azure Cognitive Services containers aren't licensed to run without being connected to the metering / billing endpoint. You must enable the containers to communicate billing information with the billing endpoint at all times. Cognitive Services containers don't send customer data, such as the image or text that's being analyzed, to Microsoft.

Connect to Azure

The container needs the billing argument values to run. These values allow the container to connect to the billing endpoint. The container reports usage about every 10 to 15 minutes. If the container doesn't connect to Azure within the allowed time window, the container continues to run but doesn't serve queries until the billing endpoint is restored. The connection is attempted 10 times at the same time interval of 10 to 15 minutes. If it can't connect to the billing endpoint within the 10 tries, the container stops serving requests. See the Cognitive Services container FAQ for an example of the information sent to Microsoft for billing.

Billing arguments

The docker run command will start the container when all three of the following options are provided with valid values:

OptionDescription
ApiKeyThe API key of the Cognitive Services resource that's used to track billing information.
The value of this option must be set to an API key for the provisioned resource that's specified in Billing.
BillingThe endpoint of the Cognitive Services resource that's used to track billing information.
The value of this option must be set to the endpoint URI of a provisioned Azure resource.
EulaIndicates that you accepted the license for the container.
The value of this option must be set to accept.

For more information about these options, see Configure containers.

Summary

In this article, you learned concepts and workflow for downloading, installing, and running Text Analytics containers. In summary:

  • Text Analytics provides three Linux containers for Docker, encapsulating various capabilities:
    • Sentiment Analysis
    • Key Phrase Extraction (preview)
    • Language Detection
    • Text Analytics for health
  • Container images are downloaded from the Microsoft Container Registry (MCR).
  • Container images run in Docker.
  • You can use either the REST API or SDK to call operations in Text Analytics containers by specifying the host URI of the container.
  • You must specify billing information when instantiating a container.

Important

Cognitive Services containers are not licensed to run without being connected to Azure for metering. Customers need to enable the containers to communicate billing information with the metering service at all times. Cognitive Services containers do not send customer data (e.g. text that is being analyzed) to Microsoft.

Next steps

  • See Configure containers for configuration settings.

Most Viewed Posts