Windows 2022
Sponsored Link

Docker : Docker Compose
To Install Docker Compose, it's easy to configure and run multiple containers as a Docker application.
[1] Install Docker Compose. Make sure the latest version on the site below.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> Invoke-WebRequest "" -UseBasicParsing -OutFile $Env:ProgramFiles\docker\docker-compose.exe 

PS C:\Users\Administrator> docker-compose --version 
Docker Compose version v2.2.3
[2] For example, Configure an application that has IIS services with Docker Compose.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# create Dockerfile
PS C:\Users\Administrator> mkdir docker-file 
PS C:\Users\Administrator> cd docker-file 

PS C:\Users\Administrator\docker-file> $str_file = @"

SHELL ["powershell", "-command"]
RUN Install-WindowsFeature Web-Server
RUN Invoke-WebRequest -Uri -OutFile C:\ServiceMonitor.exe


ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]

PS C:\Users\Administrator\docker-file> $str_file | Out-File Dockerfile -Encoding Default 

# define application configration
PS C:\Users\Administrator\docker-file> $str_file2 = @"
version: '3'
    build: .
      - "80:80"
      - C:\iis:C:\inetpub\wwwroot

PS C:\Users\Administrator\docker-file> $str_file2 | Out-File docker-compose.yml -Encoding Default 

PS C:\Users\Administrator\docker-file> mkdir C:\iis 

# buid and run
PS C:\Users\Administrator\docker-file> docker-compose up -d 
Sending build context to Docker daemon     513B
Step 1/6 : FROM
 ---> 11cbc9e36c7a
Step 2/6 : SHELL ["powershell", "-command"]
 ---> Running in e70646a28478
Removing intermediate container e70646a28478
 ---> 9e1231e7ae71
Step 3/6 : RUN Install-WindowsFeature Web-Server
 ---> Running in d7c2c18180cb


Step 6/6 : ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]
 ---> Running in b7ab30b05ce9
Removing intermediate container b7ab30b05ce9
 ---> db13c58d6184
Successfully built db13c58d6184
Successfully tagged docker-file_web:latest
[+] Running 1/1
 - Container docker-file-web-1  Started

PS C:\Users\Administrator\docker-file> docker ps 
CONTAINER ID   IMAGE              COMMAND                   CREATED          STATUS          PORTS                NAMES
71bdab92e0d5   docker-file_web   "C:\\ServiceMonitor.e…"   19 seconds ago   Up 17 seconds>80/tcp   docker-file-web-1

# create a test file
PS C:\Users\Administrator\docker-file> Write-Output "Docker Compose Test Page" | Out-File C:\iis\Default.htm -Encoding Default 

# verify accesses
PS C:\Users\Administrator\docker-file> curl.exe localhost 
Docker Compose Test Page
[3] Other basic operations of Docker Compose are follows.
PS C:\Users\Administrator\docker-file> docker-compose ps 
NAME                 COMMAND                   SERVICE             STATUS              PORTS
docker-file-web-1   "C:\\ServiceMonitor.e…"   web                 running   >80/tcp

# run any commands inside a container
# container name is just the one set in [docker-compose.yml]
PS C:\Users\Administrator\docker-file> docker-compose exec web powershell 

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements!

PS C:\> hostname 

PS C:\> exit 

# stop application and also shutdown all containers
PS C:\Users\Administrator\docker-file> docker-compose stop 
[+] Running 1/1
 - Container docker-file-web-1  Stopped

# to start application again, run like follows
PS C:\Users\Administrator\docker-file> docker-compose up 
[+] Running 1/0
 - Container docker-file-web-1  Created      0.0s
Attaching to docker-file-web-1

# remove all containers in application
# if a container is running, it won't be removed
PS C:\Users\Administrator\docker-file> docker-compose rm 
? Going to remove docker-file-web-1 Yes
[+] Running 1/0ve docker-file-web-1 (y/N) y
 - Container docker-file-web-1  Removed
Matched Content