본문 바로가기
카테고리 없음

Windows Server 2019에서 Docker 컨테이너를 실행하는 방법

by kogoza 2020. 5. 12.
반응형

Windows Server 2019에서 Docker 컨테이너를 실행하는 방법

Windows 컨테이너를 사용하여 시스템에서 여러 개의 격리 된 응용 프로그램을 실행하려면 컨테이너 기능을 활성화하고 Windows Server 2019에 Docker를 설치해야합니다.

1 단계 : Windows Server 2019에서 컨테이너 기능 사용

첫 번째 단계는 Windows Server 2019 컨테이너 기능을 활성화하는 것입니다. 관리자 권한으로 PowerShell을 엽니 다.

다음 명령을 실행하십시오.

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

샘플 출력은 다음과 같습니다.

2 단계 : Windows Server 2019에 Docker 설치

Windows Server 2019에서 컨테이너 기능이 활성화되면 PowerShell 세션에서 아래 명령을 실행하여 최신 Docker Engine 및 Client를 설치하십시오.

Install-Package -Name docker -ProviderName DockerMsftProvider

Install-Package -Name docker -ProviderName DockerMsftProvider

“예”또는“Y”또는“A”를 사용하여 설치에 동의하면 모두에 동의합니다.

설치가 완료되면 컴퓨터를 재부팅하십시오.

Restart-Computer -Force

Restart-Computer -Force

설치된 Docker 버전은 다음을 통해 확인할 수 있습니다.

Administrator> Get-Package -Name Docker -ProviderName DockerMsftProvider
Name Version Source ProviderName
---- ------- ------ ------------
docker 18.09.2 DockerDefault DockerMsftProvider

PS C:\Users\Administrator> docker version
Client:
Version: 18.09.2
API version: 1.39
Go version: go1.10.6
Git commit: 1ac774dfdd
Built: unknown-buildtime
OS/Arch: windows/amd64
Experimental: false
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.39/version: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.39/version: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

dministrator> Get-Package -Name Docker -ProviderName DockerMsftProviderName Version Source ProviderName---- ------- ------ ------------docker 18.09.2 DockerDefault DockerMsftProviderPS C:\Users\Administrator> docker versionClient:Version: 18.09.2API version: 1.39Go version: go1.10.6Git commit: 1ac774dfddBuilt: unknown-buildtimeOS/Arch: windows/amd64Experimental: falseerror during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.39/version: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.39/version: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

PowerShell에서 다음 명령을 실행하여 언제든지 업그레이드를 수행 할 수 있습니다.

Install-Package -Name Docker -ProviderName DockerMsftProvider -Update -Force
Start-Service Docker

Install-Package -Name Docker -ProviderName DockerMsftProvider -Update -ForceStart-Service Docker

3 단계 : Docker 컨테이너 실행

도커 데몬 시작

Start-Service Docker

Start-Service Docker

Docker Engine 서비스를 시작한 후 Docker Hub 레지스트리에서 사전 작성된 .NET 샘플 이미지를 다운로드하십시오 .

docker pull microsoft/dotnet-samples:dotnetapp-nanoserver-1809

docker pull microsoft/dotnet-samples:dotnetapp-nanoserver-1809

그런 다음 .Net Hello World 애플리케이션을 실행하는 간단한 컨테이너를 배치하십시오.

docker run microsoft/dotnet-samples:dotnetapp-nanoserver-1809

docker run microsoft/dotnet-samples:dotnetapp-nanoserver-1809

컨테이너가 시작되고 hello world 메시지를 인쇄 한 다음 종료됩니다.

Windows Server 2019에서 Linux 컨테이너 실행

Windows의 Docker는 기본적으로 Windows 컨테이너 만 실행합니다. Windows Server에서 Linux 컨테이너를 사용하려면 Docker Linux 컨테이너를 실행하기위한 전체 LinuxKit 시스템이 포함 된 Docker Enterprise Edition Preview를 사용해야합니다.

현재 Docker CE를 제거하십시오.

Uninstall-Package -Name docker -ProviderName DockerMSFTProvider

Uninstall-Package -Name docker -ProviderName DockerMSFTProvider

Hyper-V에서 실행되는 Linux 가상 머신을 사용하여 Docker 컨테이너를 실행중인 경우 중첩 가상화를 사용하십시오.

Get-VM WinContainerHost | Set-VMProcessor -ExposeVirtualizationExtensions $true

Get-VM WinContainerHost | Set-VMProcessor -ExposeVirtualizationExtensions $true

그런 다음 Docker EE의 현재 미리보기 빌드를 설치하십시오.

Install-Module DockerProvider
Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview

Install-Module DockerProviderInstall-Package Docker -ProviderName DockerProvider -RequiredVersion preview

Linux 컨테이너를 실행하기 위해 LinuxKit 시스템 사용

[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")

[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")

변경 후 Docker 서비스를 다시 시작하십시오.

Restart-Service docker

Restart-Service docker

테스트 도커 이미지를 당깁니다.

> docker run -it --rm ubuntu /bin/bash
root@1440a7fef7e0:/# cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

root@1440a7fef7e0:/# exit
exit

> docker run -it --rm ubuntu /bin/bashroot@1440a7fef7e0:/# cat /etc/os-release NAME="Ubuntu"VERSION="18.04.1 LTS (Bionic Beaver)"ID=ubuntuID_LIKE=debianPRETTY_NAME="Ubuntu 18.04.1 LTS"VERSION_ID="18.04"HOME_URL="https://www.ubuntu.com/"https://www.ubuntu.com/"SUPPORT_URL="https://help.ubuntu.com/"https://help.ubuntu.com/"BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"https://bugs.launchpad.net/ubuntu/"PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"VERSION_CODENAME=bionicUBUNTU_CODENAME=bionicroot@1440a7fef7e0:/# exitexit

실행중인 Windows 컨테이너로 다시 전환하려면 다음을 실행하십시오.

[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "$null", "Machine")

[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "$null", "Machine")

 

반응형

댓글