Introduction
Docker is an open-source platform that enables developers to automate the deployment, scaling, and management of applications through containerization. Containers encapsulate an application and its dependencies, ensuring consistent behavior across different environments.
Overview
This document provides a comprehensive overview of Docker, covering the What, Who, Where, When, Why, How, Consequences, and Conclusion.
What
Docker is a platform that uses OS-level virtualization to deliver software in packages called containers. These containers are lightweight, portable, and can run on any system that supports Docker, making it easier to manage and deploy applications consistently across different environments.
Who
Docker is designed for developers, IT professionals, and system administrators who need to create, test, and deploy applications quickly and reliably. It is used by startups, enterprises, and individual developers worldwide for various applications and services.
Where
Docker can be deployed on various platforms, including Windows, macOS, and Linux. It is widely used in development environments, production systems, and cloud-based infrastructure.
When
Docker was first released in 2013 and has since become a foundational tool in modern DevOps practices. It has evolved through numerous updates to include new features and enhancements, continually expanding its capabilities.
Why
Understanding the pros and cons of Docker can help determine its suitability for various use cases.
Pros | Cons |
---|---|
Portability across different environments | Requires learning curve for setup and management |
Efficient resource usage | Potential security risks if not properly managed |
Consistent and reproducible deployments | Overhead from container orchestration |
How
Here is a basic workflow to set up and manage Docker:
Step 1 | Install Docker on your chosen platform |
Step 2 | Create a Dockerfile to define the environment for your application |
Step 3 | Build and run the Docker container using Docker commands |
Consequences
The implementation of Docker brings various positive and negative consequences:
Positive |
|
Negative |
|
Conclusion
Docker is a powerful platform that offers numerous benefits, such as portability, efficient resource usage, and consistent deployments. However, it also has some limitations, including a learning curve and potential security risks. Overall, Docker is an essential tool for modern software development and deployment, providing significant advantages in terms of speed, scalability, and manageability.
Install and Configure
Install Docker that is the Operating System-Level Virtualization Tool, that automates the deployment of applications inside Containers. On Windows Server 2019, Hyper-V is not required for installing Docker, only [Containers] feature is needed.
Using Command Line Interface (CLI)
Step [1]Run PowerShell with Admin Privilege and Install Docker.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# install [Containers] feature
# restart after inputting [Y(es)]
PS C:\Users\Administrator> Enable-WindowsOptionalFeature -Online -FeatureName Containers
Do you want to restart the computer to complete this operation now?
[Y] Yes [N] No [?] Help (default is "Y"): Y
# after restarting, install Docker
PS C:\Users\Administrator> Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet
provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\Administrator\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the
NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
PS C:\Users\Administrator> Install-Package -Name docker -ProviderName DockerMsftProvider
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'DockerDefault'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
Name Version Source Summary
---- ------- ------ -------
Docker 19.03.13 DockerDefault Contains Docker EE for use with Windows Server.
# restart again
PS C:\Users\Administrator> Restart-Computer -Force
# verify status
PS C:\Users\Administrator> docker version
Client: Mirantis Container Runtime
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 0c38b2d
Built: 11/12/2020 21:33:08
OS/Arch: windows/amd64
Experimental: false
Server: Mirantis Container Runtime
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.24)
Go version: go1.13.15
Git commit: 5b5efb2d49
Built: 11/12/2020 21:31:44
OS/Arch: windows/amd64
Experimental: false
Using Graphical User Interface (GUI)
Step [2]Run Server Manager and start [Add roles and features], then select [Containers] feature on [Select features] section like follows to install. After installing, restart computer.
Step [3]After restarting, Run PowerShell with Admin Privilege and Install Docker. Answer Y (Yes) to all confirmations during the installation.
PS > Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
PS > Install-Package -Name docker -ProviderName DockerMsftProvider
Step [4]After installing, [Docker Engine] service will be added like follows. Restart computer again.
Step [5]After restarting, Run PowerShell with Admin Privilege and run docker command to verify status.
PS > docker version
Basic Usage
This is the Basic Usage of Docker. Run PowerShell or Command Prompt to use it.
Step [1]Download Windows official image and run [echo] inside a Container. It's impossible to run Containers if the Version of Host Windows and Container Windows are not the same one, so specify a specific version when pulling an image. Refer to the official documents below for version compatibility. ⇒ https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# pull Windows ServerCore image
PS C:\Users\Administrator> docker pull mcr.microsoft.com/windows/servercore:1809
1809: Pulling from windows/servercore
65014b3c3121: Pull complete
9e2f2b17be72: Pull complete
Digest: sha256:17752cc071661e3cc1c1bec27d90d528fb4389d90c0412466783c2fe1c291c4e
Status: Downloaded newer image for mcr.microsoft.com/windows/servercore:1809
# display images
PS C:\Users\Administrator> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mcr.microsoft.com/windows/servercore 1809 640a8acbeb6f 33 hours ago 4.28GB
# run echo inside a container
PS C:\Users\Administrator> docker run mcr.microsoft.com/windows/servercore:1809 powershell -c "echo 'Hello Windows Container World'"
Hello Windows Container World
Step [2]Connect to the interactive session of a Container with [i] and [t] option like follows. If [exit] from the Container session, the process of a Container finishes.
PS C:\Users\Administrator> docker run -it mcr.microsoft.com/windows/servercore:1809 powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\> systeminfo
Host Name: 172DABD6959C
OS Name: Microsoft Windows Server 2019 Datacenter Evaluation
OS Version: 10.0.17763 N/A Build 17763
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
Original Install Date: 2/7/2019, 8:25:07 PM
System Boot Time: 2/13/2019, 11:47:45 PM
System Boot Time: 2/13/2019, 11:47:45 PM
System Manufacturer: Red Hat
System Model: KVM
System Type: x64-based PC
Processor(s): 4 Processor(s) Installed.
[01]: Intel64 Family 6 Model 60 Stepping 4 GenuineIntel ~2594 Mhz
System Boo [02]: Intel64 Family 6 Model 60 Stepping 4 GenuineIntel ~2594 Mhz
System Man [03]: Intel64 Family 6 Model 60 Stepping 4 GenuineIntel ~2594 Mhz
System Mod [04]: Intel64 Family 6 Model 60 Stepping 4 GenuineIntel ~2594 Mhz
.....
.....
PS C:\> exit
PS C:\Users\Administrator> # back
Step [3]If exit from the Container session with keeping container's process, push Ctrl+p, and Ctrl+q key.
PS C:\Users\Administrator> docker run -it mcr.microsoft.com/windows/servercore:1809 powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\> # Ctrl+p, Ctrl+q
PS C:\Users\Administrator>
PS C:\Users\Administrator> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e68a751d4b2c mcr.microsoft.com/windows/servercore:1809 "powershell" 42 seconds ago Up 39 seconds silly_volhard
# connect to container's session
PS C:\Users\Administrator> docker attach e68a751d4b2c
PS C:\> hostname
e68a751d4b2c
PS C:\>
# shutdown container's process from Host's console
PS C:\Users\Administrator> docker kill e68a751d4b2c
e68a751d4b2c
PS C:\Users\Administrator> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Add Container Images
Add your customized images for Containers.
Step [1]For exmaple, Install IIS and add it as a new image for container. The container is generated every time for executing docker run command, so add the latest executed container like follows.
# display images
PS C:\Users\Administrator> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mcr.microsoft.com/windows/servercore 1809 640a8acbeb6f 6 days ago 4.28GB
# start a Container and install IIS
PS C:\Users\Administrator> docker run mcr.microsoft.com/windows/servercore:1809 powershell -c "dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart"
Deployment Image Servicing and Management tool
Version: 10.0.17763.1
Image Version: 10.0.17763.316
Enabling feature(s)
The operation completed successfully.
PS C:\Users\Administrator> (docker ps -a)[0..1]
CONTAINER ID IMAGE COMMAND CREATED STATUS
PORTS NAMES
b8935d684c30 mcr.microsoft.com/windows/servercore:1809 "powershell -c 'dism" 2 minutes ago Exited (0) About a minute ago serene_brahmagupta
# add the image
PS C:\Users\Administrator> docker commit b8935d684c30 bizantum.lab/iis
sha256:1f0cbc310aaa3c4f508827dc59be7d5def17235abfbf1fc335b6eafadc4961c5
# display images
PS C:\Users\Administrator> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bizantum.lab/iis latest 1f0cbc310aaa 30 seconds ago 4.43GB
mcr.microsoft.com/windows/servercore 1809 640a8acbeb6f 6 days ago 4.28GB
# generate a container from the new image and verify IIS is running to access to container's localhost
PS C:\Users\Administrator> docker run bizantum.lab/iis powershell -c "curl.exe localhost"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>IIS Windows Server</title>
<style type="text/css">
.....
.....
Access Services on Container
If you'd like to access to services like HTTP or SSH which is running on Containers as a daemon, set like follows.
Step [1]For exmaple, run a container to use the container image which has IIS service like the example of here.
# map the port of Host and the port of Container with [-p xxx:xxx]
PS C:\Users\Administrator> docker run -t -d -p 8081:80 bizantum.lab/iis cmd
ce3bfb401c6ea52f1f640fc5141932017515366d75acfb902405cbe569ca0d92
PS C:\Users\Administrator> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce3bfb401c6e bizantum.lab/iis "cmd" 32 seconds ago Up 27 seconds 0.0.0.0:8081->80/tcp blissful_nobel
# create a test page
PS C:\Users\Administrator> docker exec ce3bfb401c6e powershell -c "Write-Output 'IIS on Docker Container' | Out-File -Encoding default C:\inetpub\wwwroot\index.html"
Step [2]Verify the test page is shown normally to access to [localhost:8081] on Parent Host.
Use Dockerfile
Use Dockerfile and create Docker images automatically. It is also useful for configuration management.
Step [1]For example, Create a Dockerfile to install IIS.
PS C:\Users\Administrator> mkdir docker-test
PS C:\Users\Administrator\docker-test> cd docker-test
PS C:\Users\Administrator\docker-test> $str_file = @"
FROM mcr.microsoft.com/windows/servercore:1809
MAINTAINER ServerWorld <admin@bizantum.lab>
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
RUN echo Dockerfile test example > C:\inetpub\wwwroot\index.html
EXPOSE 80
CMD [ "cmd" ]
"@
PS C:\Users\Administrator\docker-test> $str_file | Out-File Dockerfile -Encoding Default
# build image ⇒ docker build -t [image name]:[tag] .
PS C:\Users\Administrator\docker-test> docker build -t bizantum.lab/iis-server:latest .
Sending build context to Docker daemon 2.048kB
Step 1/6 : FROM mcr.microsoft.com/windows/servercore:1809
---> 5c1f582f60a9
Step 2/6 : MAINTAINER ServerWorld <admin@bizantum.lab>
---> Running in 48d196707126
Removing intermediate container 48d196707126
---> e6345d98e44b
Step 3/6 : RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
---> Running in 8435c833b7c6
.....
.....
Successfully built d0b43de1e6a4
Successfully tagged bizantum.lab/iis-server:latest
PS C:\Users\Administrator\docker-test> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bizantum.lab/iis-server latest d0b43de1e6a4 About a minute ago 5.32GB
mcr.microsoft.com/windows/servercore 1809 5c1f582f60a9 12 days ago 5.12GB
# run Container on background
PS C:\Users\Administrator\docker-test> docker run -t -d -p 8081:80 bizantum.lab/iis-server
ebd915020c61c0f0ed21b4a277ed14eb4e8eb1d863bfd7c42136ffcd1343a70f
PS C:\Users\Administrator\docker-test> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NA
MES
ebd915020c61 bizantum.lab/iis-server "cmd" 9 seconds ago Up 8 seconds 0.0.0.0:8081->80/tcp nervous_hypatia
# verify accesses
PS C:\Users\Administrator\docker-test> curl.exe localhost:8081
Dockerfile test example
Use Persistent Storage
When Container is removed, data in it are also lost, so it's necessary to use external filesystem in Containers as persistent storage if you'd like to save data.
Step [1]It's possible to mount a directory on Docker Host into Containers.
# create a directory for data
PS C:\Users\Administrator> mkdir C:\docker-storage
# create a test file
PS C:\Users\Administrator> Write-Output 'Docker Persistent Storage Test' | Out-File -Encoding default C:\docker-storage\index.html
# run a container with mounting the directory above on [C:\disk01]
PS C:\Users\Administrator> docker run -it -v C:\docker-storage:C:\disk01 mcr.microsoft.com/windows/servercore:1809
Microsoft Windows [Version 10.0.17763.1637]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\> dir C:\
Volume in drive C has no label.
Volume Serial Number is 6CA1-73D3
Directory of C:\
12/15/2020 08:07 PM <DIR> disk01
05/06/2020 08:48 PM 5,510 License.txt
12/03/2020 06:14 PM <DIR> Program Files
12/03/2020 06:12 PM <DIR> Program Files (x86)
12/03/2020 06:15 PM <DIR> Users
12/15/2020 08:09 PM <DIR> Windows
1 File(s) 5,510 bytes
5 Dir(s) 21,199,335,424 bytes free
C:\> type C:\disk01\index.html
Docker Persistent Storage Test
Step [2]It's also possible to configure external storage by Docker Data Volume command.
# create [volume01] volume
PS C:\Users\Administrator> docker volume create volume01
volume01
# display volume list
PS C:\Users\Administrator> docker volume ls
DRIVER VOLUME NAME
local volume01
# display details of [volume01]
PS C:\Users\Administrator> docker volume inspect volume01
[
{
"CreatedAt": "2020-12-15T20:17:47-08:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "C:\\ProgramData\\docker\\volumes\\volume01\\_data",
"Name": "volume01",
"Options": {},
"Scope": "local"
}
]
# run a container with mounting [volume01] to [C:\disk01] on container
PS C:\Users\Administrator> docker run -it -v volume01:C:\disk01 mcr.microsoft.com/windows/servercore:1809 powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\> ls C:\
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 12/15/2020 8:17 PM disk01
d-r--- 12/3/2020 6:14 PM Program Files
d----- 12/3/2020 6:12 PM Program Files (x86)
d-r--- 12/3/2020 6:15 PM Users
d----- 12/15/2020 8:31 PM Windows
-a---- 5/6/2020 9:48 PM 5510 License.txt
PS C:\> echo "Docker Volume test" | Out-File C:\disk01\testfile.txt -Encoding Default
PS C:\> exit
PS C:\Users\Administrator> Get-Content C:\ProgramData\docker\volumes\volume01\_data\testfile.txt
Docker Volume test
# possible to mount from other containers
PS C:\Users\Administrator> docker run -v volume01:C:\volume01 mcr.microsoft.com/windows/servercore:1809 powershell -c "Get-Content C:\volume01\testfile.txt"
Docker Volume test
# to remove volumes, do like follows
PS C:\Users\Administrator> docker volume rm volume01
Error response from daemon: remove volume01: volume is in use - [1864ecc444276667189e5c5cd099e38554a316d73b755670a5835742df673588, 89c96e683cb5ebf4a0bdb8614a0f53bf81a7dd0c345a2e45ce0be7cd61e0434c]
# if some containers are using the volume you'd like to remove like above,
# it needs to remove target containers before removing a volume
PS C:\Users\Administrator> docker rm 1864ecc444276667189e5c5cd099e38554a316d73b755670a5835742df673588
PS C:\Users\Administrator> docker rm 89c96e683cb5ebf4a0bdb8614a0f53bf81a7dd0c345a2e45ce0be7cd61e0434c
PS C:\Users\Administrator> docker volume rm volume01
volume01
Network
This is the basic usage to configure Docker Network.
Step [1]When running containers without specifying network, default [nat] network is assigned.
# display network list
PS C:\Users\Administrator> docker network ls
NETWORK ID NAME DRIVER SCOPE
835e5265281e administrator_default nat local
84fb0716e654 nat nat local
4a4ab2bf8de9 none null local
# display details of [nat]
PS C:\Users\Administrator> docker network inspect nat
[
{
"Name": "nat",
"Id": "84fb0716e654da933857ea23cf9b7bb45c615583af0df2586281dc7099786326",
"Created": "2020-12-15T22:03:50.6680838-08:00",
"Scope": "local",
"Driver": "nat",
"EnableIPv6": false,
"IPAM": {
"Driver": "windows",
"Options": null,
"Config": [
{
"Subnet": "172.18.224.0/20",
"Gateway": "172.18.224.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.windowsshim.hnsid": "848A89F5-CFB3-4D77-818A-3DC49C4C6DFB",
"com.docker.network.windowsshim.networkname": "nat"
},
"Labels": {}
}
]
# [nat] is assigned as container network by default
PS C:\Users\Administrator> docker run mcr.microsoft.com/windows/servercore:1809 powershell -c "ipconfig"
Windows IP Configuration
Ethernet adapter vEthernet (Ethernet):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::f017:c45a:9576:257a%21
IPv4 Address. . . . . . . . . . . : 172.18.232.152
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . : 172.18.224.1
Step [2]If you'd like to assign another network, set like follows.
# create network [network01] with [192.168.100.0/24] subnet
PS C:\Users\Administrator> docker network create -d "nat" --subnet "192.168.100.0/24" network01
b6ccadd1101d02118f69b1649e33e9b56f88152fd0ed56da647ba5feeb7d18e3
PS C:\Users\Administrator> docker network ls
NETWORK ID NAME DRIVER SCOPE
835e5265281e administrator_default nat local
84fb0716e654 nat nat local
b6ccadd1101d network01 nat local
4a4ab2bf8de9 none null local
# run a container with specifying [network01]
PS C:\Users\Administrator> docker run --net network01 mcr.microsoft.com/windows/servercore:1809 powershell -c "ipconfig"
Windows IP Configuration
Ethernet adapter vEthernet (Ethernet):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::6973:b329:3b79:68df%25
IPv4 Address. . . . . . . . . . . : 192.168.100.206
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.100.1
# to attach the network to existing running container, set like follows
PS C:\Users\Administrator> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43f4fd5c7833 bizantum.lab/iis "cmd" 10 seconds ago Up 8 seconds 0.0.0.0:8081->80/tcp quirky_hermann
PS C:\Users\Administrator> docker exec 43f4fd5c7833 powershell -c "ipconfig"
Windows IP Configuration
Ethernet adapter vEthernet (Ethernet):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::480c:fc3b:6b06:a363%25
IPv4 Address. . . . . . . . . . . : 172.18.228.192
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . : 172.18.224.1
# attach network to specify an IP address in the subnet
PS C:\Users\Administrator> docker network connect --ip 192.168.100.10 network01 43f4fd5c7833
PS C:\Users\Administrator> docker exec 43f4fd5c7833 powershell -c "ipconfig"
Windows IP Configuration
Ethernet adapter vEthernet (Ethernet):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::480c:fc3b:6b06:a363%25
IPv4 Address. . . . . . . . . . . : 172.18.228.192
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . : 172.18.224.1
Ethernet adapter vEthernet (Ethernet) 2:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::d9ca:8ddc:a838:cdc%29
IPv4 Address. . . . . . . . . . . : 192.168.100.10
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.100.1
# to disconnect the network, set like follows
PS C:\Users\Administrator> docker network disconnect network01 43f4fd5c7833
PS C:\Users\Administrator> docker exec 43f4fd5c7833 powershell -c "ipconfig"
Windows IP Configuration
Ethernet adapter vEthernet (Ethernet):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::480c:fc3b:6b06:a363%25
IPv4 Address. . . . . . . . . . . : 172.18.228.192
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . : 172.18.224.1
Step [3]To remove docker networks, set like follows.
PS C:\Users\Administrator> docker network ls
NETWORK ID NAME DRIVER SCOPE
835e5265281e administrator_default nat local
84fb0716e654 nat nat local
b6ccadd1101d network01 nat local
4a4ab2bf8de9 none null local
# remove [network01]
PS C:\Users\Administrator> docker network rm network01
network01
# remove networks which containers don't use at all
PS C:\Users\Administrator> docker network prune
WARNING! This will remove all custom networks not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Networks:
administrator_default
Step [4]To connect to Host network, not nat, set like follows.
# confirm network adapter name
PS C:\Users\Administrator> Get-NetAdapter
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
---- -------------------- ------- ------ ---------- ---------
vEthernet (nat) Hyper-V Virtual Ethernet Adapter 9 Up 00-15-5D-9F-81-EC 10 Gbps
Ethernet Intel(R) 82574L Gigabit Network Conn... 5 Up 52-54-00-05-80-B8 1 Gbps
# create [transparent01] network with [transparent] driver
# for [com.docker.network.windowsshim.interface="***"], specify adapter name confirmed above
PS C:\Users\Administrator> docker network create -d transparent -o com.docker.network.windowsshim.interface="Ethernet" transparent01
PS C:\Users\Administrator> docker network ls
NETWORK ID NAME DRIVER SCOPE
84fb0716e654 nat nat local
4a4ab2bf8de9 none null local
83d4393b8873 transparent01 transparent local
PS C:\Users\Administrator> docker network inspect transparent01
[
{
"Name": "transparent01",
"Id": "83d4393b8873869ea6965af480b4d45ddc61995615eb96e4b4e83ce6f4c1d0e9",
"Created": "2020-12-15T23:57:06.3332974-08:00",
"Scope": "local",
"Driver": "transparent",
"EnableIPv6": false,
"IPAM": {
"Driver": "windows",
"Options": {},
"Config": [
{
"Subnet": "0.0.0.0/0"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"f655e188d62d5c595a83b51b18ff6c57519072d8fa4bd6e384760543bef979f1": {
"Name": "hungry_swirles",
"EndpointID": "42397562c0296c3763cdd704be2a761e4759b408b415a001714e839db327850e",
"MacAddress": "00:15:5d:63:80:eb",
"IPv4Address": "",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.windowsshim.hnsid": "21B4D02D-4FD6-40B9-A2A6-1E07CC138842",
"com.docker.network.windowsshim.interface": "Ethernet"
},
"Labels": {}
}
]
PS C:\Users\Administrator> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bizantum.lab/iis-server latest d0b43de1e6a4 4 hours ago 5.32GB
mcr.microsoft.com/windows/servercore 1809 5c1f582f60a9 12 days ago 5.12GB
# run a container with [transparent01] network
PS C:\Users\Administrator> docker run -t -d --net transparent01 bizantum.lab/iis-server
f655e188d62d5c595a83b51b18ff6c57519072d8fa4bd6e384760543bef979f1
PS C:\Users\Administrator> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f655e188d62d bizantum.lab/iis-server "cmd" 27 seconds ago Up 25 seconds 80/tcp hungry_swirles
# display IP address (it is assigned by DHCP server in your local network)
PS C:\Users\Administrator> docker exec f655e188d62d powershell -c "ipconfig"
Windows IP Configuration
Ethernet adapter vEthernet (Ethernet) 2:
Connection-specific DNS Suffix . : bizantum.lab
Link-local IPv6 Address . . . . . : fe80::fc34:3e2d:f775:f192%21
IPv4 Address. . . . . . . . . . . : 10.0.0.204
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.0.1
# verify accesses
PS C:\Users\Administrator> curl.exe 10.0.0.204
Dockerfile test example
- Get link
- X
- Other Apps
Comments
Post a Comment
Thank you for your comment! We appreciate your feedback, feel free to check out more of our articles.
Best regards, Bizantum Blog Team.