1
1
---
2
- title : Install and run Docker containers for Document Intelligence
2
+ title : Install and run Docker containers for Document Intelligence
3
3
titleSuffix : Azure AI services
4
4
description : Use the Docker containers for Document Intelligence on-premises to identify and extract key-value pairs, selection marks, tables, and structure from forms and documents.
5
5
author : laujan
6
6
manager : nitinme
7
7
ms.service : azure-ai-document-intelligence
8
8
ms.topic : how-to
9
- ms.date : 11/19/2024
9
+ ms.date : 01/22/2025
10
10
ms.author : lajanuar
11
11
---
12
12
@@ -272,13 +272,13 @@ services:
272
272
- AzureCognitiveServiceReadHost=http://azure-cognitive-service-read:5000
273
273
ports :
274
274
- " 5000:5050"
275
- azure-cognitive-service-read :
276
- container_name : azure-cognitive-service-read
277
- image : mcr.microsoft.com/azure-cognitive-services/form-recognizer/read-3.1
278
- environment :
279
- - EULA=accept
280
- - billing={FORM_RECOGNIZER_ENDPOINT_URI}
281
- - apiKey={FORM_RECOGNIZER_KEY}
275
+ azure-cognitive-service-read :
276
+ container_name : azure-cognitive-service-read
277
+ image : mcr.microsoft.com/azure-cognitive-services/form-recognizer/read-3.1
278
+ environment :
279
+ - EULA=accept
280
+ - billing={FORM_RECOGNIZER_ENDPOINT_URI}
281
+ - apiKey={FORM_RECOGNIZER_KEY}
282
282
` ` `
283
283
284
284
Now, you can start the service with the [**docker compose**](https://docs.docker.com/compose/) command:
@@ -345,6 +345,7 @@ services:
345
345
- apiKey={FORM_RECOGNIZER_KEY}
346
346
` ` `
347
347
348
+
348
349
### [Custom](#tab/custom)
349
350
350
351
In addition to the [prerequisites](#prerequisites), you need to do the following to process a custom document:
@@ -385,23 +386,25 @@ In addition to the [prerequisites](#prerequisites), you need to do the following
385
386
386
387
1. Declare the following environment variables :
387
388
388
- ` ` ` text
389
+ ` ` ` bash
390
+
391
+
389
392
SHARED_MOUNT_PATH="./share"
390
393
OUTPUT_MOUNT_PATH="./output"
391
394
FILE_MOUNT_PATH="./files"
392
395
DB_MOUNT_PATH="./db"
393
396
FORM_RECOGNIZER_ENDPOINT_URI="YourFormRecognizerEndpoint"
394
397
FORM_RECOGNIZER_KEY="YourFormRecognizerKey"
395
398
NGINX_CONF_FILE="./nginx.conf"
396
- ` ` `
399
+ ` ` `
397
400
398
401
# ### Create an **nginx** file
399
402
400
403
1. Name this file **nginx.conf**.
401
404
402
405
1. Enter the following configuration :
403
406
404
- ` ` ` text
407
+ ` ` ` bash
405
408
worker_processes 1;
406
409
407
410
events { worker_connections 1024; }
@@ -443,6 +446,10 @@ http {
443
446
proxy_pass http://docker-custom/swagger;
444
447
}
445
448
449
+ location /api-docs {
450
+ proxy_pass http://docker-custom/api-docs;
451
+ }
452
+
446
453
location /formrecognizer/documentModels/prebuilt-layout {
447
454
proxy_set_header Host $host:$server_port;
448
455
proxy_set_header Referer $scheme://$host:$server_port;
@@ -491,6 +498,9 @@ http {
491
498
}
492
499
493
500
` ` `
501
+ :: : moniker-end
502
+
503
+ :::moniker range="<=doc-intel-3.0.0"
494
504
495
505
# ### Create a **docker compose** file
496
506
@@ -506,7 +516,94 @@ services:
506
516
container_name: reverseproxy
507
517
depends_on:
508
518
- layout
509
- - custom-template
519
+ - custom-template
520
+ volumes:
521
+ - ${NGINX_CONF_FILE}:/etc/nginx/nginx.conf
522
+ ports:
523
+ - "5000:5000"
524
+ layout:
525
+ container_name: azure-cognitive-service-layout
526
+ image: mcr.microsoft.com/azure-cognitive-services/form-recognizer/layout-3.0:latest
527
+ environment:
528
+ eula: accept
529
+ apikey: ${FORM_RECOGNIZER_KEY}
530
+ billing: ${FORM_RECOGNIZER_ENDPOINT_URI}
531
+ Logging:Console:LogLevel:Default: Information
532
+ SharedRootFolder: /share
533
+ Mounts:Shared: /share
534
+ Mounts:Output: /logs
535
+ volumes:
536
+ - type: bind
537
+ source: ${SHARED_MOUNT_PATH}
538
+ target: /share
539
+ - type: bind
540
+ source: ${OUTPUT_MOUNT_PATH}
541
+ target: /logs
542
+ expose:
543
+ - "5000"
544
+
545
+ custom-template:
546
+ container_name: azure-cognitive-service-custom-template
547
+ image: mcr.microsoft.com/azure-cognitive-services/form-recognizer/custom-template-3.0:latest
548
+ restart: always
549
+ depends_on:
550
+ - layout
551
+ environment:
552
+ AzureCognitiveServiceLayoutHost: http://azure-cognitive-service-layout:5000
553
+ eula: accept
554
+ apikey: ${FORM_RECOGNIZER_KEY}
555
+ billing: ${FORM_RECOGNIZER_ENDPOINT_URI}
556
+ Logging:Console:LogLevel:Default: Information
557
+ SharedRootFolder: /share
558
+ Mounts:Shared: /share
559
+ Mounts:Output: /logs
560
+ volumes:
561
+ - type: bind
562
+ source: ${SHARED_MOUNT_PATH}
563
+ target: /share
564
+ - type: bind
565
+ source: ${OUTPUT_MOUNT_PATH}
566
+ target: /logs
567
+ expose:
568
+ - "5000"
569
+
570
+ studio:
571
+ container_name: form-recognizer-studio
572
+ image: mcr.microsoft.com/azure-cognitive-services/form-recognizer/studio:3.0
573
+ environment:
574
+ ONPREM_LOCALFILE_BASEPATH: /onprem_folder
575
+ STORAGE_DATABASE_CONNECTION_STRING: /onprem_db/Application.db
576
+ volumes:
577
+ - type: bind
578
+ source: ${FILE_MOUNT_PATH} # path to your local folder
579
+ target: /onprem_folder
580
+ - type: bind
581
+ source: ${DB_MOUNT_PATH} # path to your local folder
582
+ target: /onprem_db
583
+ ports:
584
+ - "5001:5001"
585
+ user: "1000:1000" # echo $(id -u):$(id -g)
586
+
587
+ ` ` `
588
+ :: : moniker-end
589
+
590
+ :::moniker range=">=doc-intel-3.1.0"
591
+
592
+ # ### Create a **docker compose** file
593
+
594
+ 1. Name this file **docker-compose.yml**
595
+
596
+ 2. The following code sample is a self-contained `docker compose` example to run Document Intelligence Layout, Studio, and Custom template containers together. With `docker compose`, you use a YAML file to configure your application's services. Then, with `docker-compose up` command, you create and start all the services from your configuration.
597
+
598
+ ` ` ` yml
599
+ version: '3.3'
600
+ services:
601
+ nginx:
602
+ image: nginx:alpine
603
+ container_name: reverseproxy
604
+ depends_on:
605
+ - layout
606
+ - custom-template
510
607
volumes:
511
608
- ${NGINX_CONF_FILE}:/etc/nginx/nginx.conf
512
609
ports:
@@ -559,7 +656,7 @@ services:
559
656
560
657
studio:
561
658
container_name: form-recognizer-studio
562
- image: mcr.microsoft.com/azure-cognitive-services/form-recognizer/studio:3.0
659
+ image: mcr.microsoft.com/azure-cognitive-services/form-recognizer/studio:3.1
563
660
environment:
564
661
ONPREM_LOCALFILE_BASEPATH: /onprem_folder
565
662
STORAGE_DATABASE_CONNECTION_STRING: /onprem_db/Application.db
@@ -575,6 +672,7 @@ services:
575
672
user: "1000:1000" # echo $(id -u):$(id -g)
576
673
577
674
` ` `
675
+ :: : moniker-end
578
676
579
677
The custom template container and Layout container can use Azure Storage queues or in memory queues. The `Storage:ObjectStore:AzureBlob:ConnectionString` and `queue:azure:connectionstring` environment variables only need to be set if you're using Azure Storage queues. When running locally, delete these variables.
580
678
@@ -635,20 +733,21 @@ $b64String = [System.Convert]::ToBase64String($bytes, [System.Base64FormattingOp
635
733
Use the build model API to post the request.
636
734
637
735
` ` ` http
638
- POST http://localhost:5000/formrecognizer/documentModels:build?api-version=2023-07-31
639
-
640
- {
641
- "modelId": "mymodel",
642
- "description": "test model",
643
- "buildMode": "template",
644
-
645
- "base64Source": "<Your base64 encoded string>",
646
- "tags": {
647
- "additionalProp1": "string",
648
- "additionalProp2": "string",
649
- "additionalProp3": "string"
650
- }
651
- }
736
+
737
+ POST http://localhost:5000/formrecognizer/documentModels:build?api-version=2023-07-31
738
+
739
+ {
740
+ "modelId": "mymodel",
741
+ "description": "test model",
742
+ "buildMode": "template",
743
+
744
+ "base64Source": "<Your base64 encoded string>",
745
+ "tags": {
746
+ "additionalProp1": "string",
747
+ "additionalProp2": "string",
748
+ "additionalProp3": "string"
749
+ }
750
+ }
652
751
` ` `
653
752
654
753
---
@@ -720,4 +819,4 @@ That's it! In this article, you learned concepts and workflows for downloading,
720
819
* [Document Intelligence container configuration settings](configuration.md)
721
820
722
821
* [Azure container instance recipe](../../../ai-services/containers/azure-container-instance-recipe.md)
723
- :: : moniker-end
822
+
0 commit comments