๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
DevOps/Docker

[Docker] Windows ๋„์ปค ์„ค์น˜

by ๐ŸŒปโ™š 2021. 10. 6.

Windows์™€ Docker

์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Windows ๋„์ปค ์„ค์น˜ํ•˜๋Š” ๋‚ด์šฉ์„ ๋‹ค๋ฃฌ๋‹ค. Docker๋Š” ๋ฆฌ๋ˆ…์Šค๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฆฌ๋ˆ…์Šค ์šด์˜์ฒด์ œ ์œ„์—์„œ ๋Œ์•„๊ฐ€์•ผํ•œ๋‹ค. Linux ๊ณ„์—ด ์ด์™ธ์˜ ์šด์˜์ฒด์ œ์—์„œ ๋„์ปค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‹ค๋ฅธ ํˆด์„ ์ด์šฉํ•ด์•ผํ•œ๋‹ค.

 

Windows ์šด์˜ํ™˜๊ฒฝ์—์„œ ๋„์ปค๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์กด์žฌํ•œ๋‹ค.

  • Hyper-V ์˜ต์…˜ –> Bare Metal Hypervisor ์‚ฌ์šฉ
  • Docker Toolbox –> Hosted Hypervisor ์‚ฌ์šฉ (Deprecated)

๋‘˜์˜ ์ฐจ์ด๋Š”

 

  • Hyper-V ์˜ต์…˜ : OS๊ฐ€ ์ž์ฒด ๊ฐ€์ƒํ™”๋ฅผ ์ง€์›
  • Docker Toolbox : VMWare, VirtualBox์™€ ๊ฐ™์€ Hosted Hypervisor๋ฅผ ํ†ตํ•ด ๊ฐ€์ƒํ™”ํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

์ฆ‰, Linux๋ฅผ ๊ฐ€์ƒํ™”ํ•ด์„œ ๊ทธ ์œ„์— ๋„์ปค๋ฅผ ๋„์šฐ๋Š” ๊ฒƒ ์ด๋‹ค.

 

 

Docker Toolbox Deprecated

Docker Toolbox๋Š” Windows๋‚˜ ๋งฅ ์šด์˜์ฒด์ œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ์šฉ์ž๋“ค์ด ํŽธํ•˜๊ฒŒ Docker๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ๊ฐœ๋ฐœ์ด ๋˜์—ˆ๋‹ค. Windows 10 ์ด์ „์—๋Š” ํ•˜๋“œ์›จ์–ด ๋‹จ์—์„œ ๊ฐ€์ƒํ™”๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์•„ VMware๋‚˜ Virtualbox์™€ ๊ฐ™์€ Hosted Hypervisor๋ฅผ ์ด์šฉํ•ด์„œ ๋„์ปค๋ฅผ ๊ธฐ๋™ํ–ˆ๋‹ค.

 

๊ทธ๋Ÿฌ๋‚˜, Windows 10๋ถ€ํ„ฐ Hyper-V(ํ•˜๋“œ์›จ์–ด ๊ฐ€์ƒํ™”) ๊ธฐ๋Šฅ์„ ์ง€์›ํ–ˆ๊ณ  ๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ์šฉ์ž๊ฐ€ Windows 10 ๋ฒ„์ „์œผ๋กœ ๋„˜์–ด๊ฐ€๋ฉด์„œ Docker๋Š” ๋” ์ด์ƒ Docker Toolbox๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ๋‹ค. Virtualbox 6.0 ์ดํ›„๋กœ ๋ถ€ํ„ฐ๋Š” Hyper-V์™€ ๋ณ‘ํ–‰ํ•ด์„œ ์‹คํ–‰์ด ๊ฐ€๋Šฅํ•ด์ ธ Docker์™€ Virtualbox๋ฅผ ๊ฐ™์ด ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๊ฒŒ ๋˜์—ˆ๋‹ค. Windows Home ์œ ์ €๋Š” WSL 2๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด Docker Desktop์€ ์ด๋ฅผ ์ด์šฉํ•ด์„œ Docker Desktop on Windows Home์„ ์ œ๊ณตํ•œ๋‹ค.

 

์ด๋Ÿฌํ•œ ๋ณ€ํ™”์™€ ํ•จ๊ป˜ Docker Toolbox๋Š” Deprecated ๋˜์—ˆ๊ณ  Windows ํ™˜๊ฒฝ์— Docker ์„ค์น˜๋ฅผ ์œ„ํ•ด Docker Desktop on Windows ๋งŒ ์ง€์›ํ•œ๋‹ค.

 

 

Docker Desktop on Windows ์„ค์น˜

Install Docker Desktop on Windows

 

Install Docker Desktop on Windows

 

docs.docker.com

  • Windows 10 ์ด์ƒ์—์„œ Docker ์„ค์น˜ ๊ฐ€๋Šฅ
  • WSL 2๋ฅผ backend์—์„œ ์‹คํ–‰ํ•ด์„œ Linuxํ™˜๊ฒฝ์— Docker๋ฅผ ๊ตฌ๋™ํ•œ๋‹ค.

 

 

WSL 2 ํ™œ์„ฑํ™”

WSL2๋ฅผ ์ด์šฉํ•˜๋ฉด Windows ํ™˜๊ฒฝ์—์„œ๋„ Linux๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๊ณ  Docker๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

 

Enable WSL 2

 

Install WSL

Install Windows Subsystem for Linux with the command, wsl --install. Use a Bash terminal on your Windows machine run by your preferred Linux distribution - Ubuntu, Debian, SUSE, Kali, Fedora, Pengwin, Alpine, and more are available.

docs.microsoft.com

์‹คํ–‰ํ•ด์•ผํ•  ๋ช…๋ น๋“ค์€ ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ PowerShell์„ ์‹คํ–‰ํ•ด์„œ ์ž‘์—…ํ•œ๋‹ค.

 

 

Linux์šฉ Windows ํ•˜์œ„ ์‹œ์Šคํ…œ ํ™œ์„ฑํ™”

PS C:\Windows\system32> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

๋ฐฐํฌ ์ด๋ฏธ์ง€ ์„œ๋น„์Šค ๋ฐ ๊ด€๋ฆฌ ๋„๊ตฌ
๋ฒ„์ „: 10.0.19041.844

์ด๋ฏธ์ง€ ๋ฒ„์ „: 10.0.19042.1165

๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋„๋ก ์„ค์ •ํ•˜๋Š” ์ค‘
[==========================100.0%==========================]
์ž‘์—…์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค.

Windows ์˜ต์…˜์„ ํ™œ์„ฑํ™”ํ•˜๋Š” ๋ช…๋ น

 

 

๊ฐ€์ƒ๋จธ์‹  ๊ธฐ๋Šฅ ํ™œ์„ฑํ™”

PS C:\Windows\system32> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

๋ฐฐํฌ ์ด๋ฏธ์ง€ ์„œ๋น„์Šค ๋ฐ ๊ด€๋ฆฌ ๋„๊ตฌ
๋ฒ„์ „: 10.0.19041.844

์ด๋ฏธ์ง€ ๋ฒ„์ „: 10.0.19042.1165

๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋„๋ก ์„ค์ •ํ•˜๋Š” ์ค‘
[==========================100.0%==========================]
์ž‘์—…์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค.

Virtual Machine Platform ๊ธฐ๋Šฅ์„ ํ™œ์„ฑํ™”ํ•œ๋‹ค.
WSL ํ™œ์„ฑํ™”๋ฅผ ์™„๋ฃŒ์‹œํ‚ค๊ธฐ ์œ„ํ•ด ์žฌ๋ถ€ํŒ… ์ง„ํ–‰ ํ•œ๋‹ค.


Linux ์ปค๋„ ์—…๋ฐ์ดํŠธ ํŒจํ‚ค์ง€ ๋‹ค์šด๋กœ๋“œ

WSL2 Linux kernel update package for x64 machines

์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค.

 

 

WSL2๋ฅผ ๊ธฐ๋ณธ ๋ฒ„์ „์œผ๋กœ ์„ค์ •

PS C:\Windows\system32> wsl --set-default-version 2
WSL 2์™€์˜ ์ฃผ์š” ์ฐจ์ด์ ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ https://aka.ms/wsl2๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”
์ž‘์—…์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค.

WSL2๋ฅผ ๊ธฐ๋ณธ ๋ฒ„์ „์œผ๋กœ ์„ค์ •
ํ˜น์‹œ๋‚˜ ‘wsl’ ๋ช…๋ น์–ด๋ฅผ ์ธ์‹คํ•  ์ˆ˜ ์—†๋‹ค๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด power shell์ด ์•„๋‹Œ ๋ช…๋ น ํ”„๋กฌํŠธ(cmd)์—์„œ ์‹คํ–‰ํ•ด๋ณธ๋‹ค.
๊ทธ๋Œ€๋กœ ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๋ฉด Windows Update๋ฅผ ๋ฐ›๊ฑฐ๋‚˜ ์š”๊ตฌ์‚ฌํ•ญ์ด ์ถฉ์กฑ๋˜์ง€ ์•Š์€ ๊ฒƒ์ด๋‹ค.

 

 

๋ฆฌ๋ˆ…์Šค ๋ฐฐํฌ๋ฅผ ์„ ํƒํ•ด์„œ ์„ค์น˜

Microsoft Store

 

Microsoft Store์—์„œ Linux ๋ฐฐํฌ๋ฅผ ์„ค์น˜ํ•œ๋‹ค.
ํ•ด๋‹น ์˜ˆ์‹œ์—์„œ๋Š” Ubuntu๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‹คํ–‰ํ•œ๋‹ค.

 

 

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username:

๊ณ„์ •์„ ์ƒ์„ฑํ•ด์ฃผ๋ฉด WSL2๋ฅผ ์‚ฌ์šฉํ•  ์ค€๋น„๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ๊ณ  Docker ์„ค์น˜๋„ ๋ชจ๋‘ ์ค€๋น„๋˜์—ˆ๋‹ค.

 

 

Docker ์„ค์น˜

Windows ํ™˜๊ฒฝ์— Docker ์„ค์น˜ํ•˜๊ธฐ ์œ„ํ•ด Docker Hub์—์„œ ์ œ๊ณตํ•˜๋Š” Docker Desktop for Windows ์„ค์น˜ํŒŒ์ผ์„ ๋‹ค์šด๋ฐ›์•„์„œ ์‹คํ–‰ํ•œ๋‹ค. ์„ค์น˜์— ์•„๋ž˜ ์ปดํฌ๋„ŒํŠธ๋“ค์ด ์ œ๊ณต๋œ๋‹ค.

 

 

  • Docker Engine
  • Docker CLI client
  • Docker Compose
  • Docker Content Trust
  • Kubernetes
  • Credential Helper

์„ค์น˜ํŒŒ์ผ์„ ์‹คํ–‰ํ•ด์„œ ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค.
WSL2๋ฅผ ์š”๊ตฌํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ๋‹ซ๊ณ  ๋กœ๊ทธ์•„์›ƒํ•œ๋‹ค.

 

 

์„ค์น˜ํ•œ Docker ์‹คํ–‰ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๊ณ  ์—”์ง„์„ ์‹œ์ž‘ํ•œ๋‹ค.

 

 

Docker ์ •์ƒ ์„ค์น˜ ํ™•์ธ

PS C:\WINDOWS\system32> docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

PS C:\WINDOWS\system32> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Windows์—์„œ ํด๋ผ์ด์–ธํŠธ ํ˜•ํƒœ๋กœ ์ œ๊ณต๋˜๊ธฐ ๋•Œ๋ฌธ์— GUI ํ”„๋กœ๊ทธ๋žจ์—์„œ ์ œ์–ด๋ฅผ ํ• ์ˆ˜ ์žˆ์ง€๋งŒ… CLI ํ˜•ํƒœ๋กœ ํ™•์ธํ•œ๋‹ค. ๋‹ค์‹œ Powershell์„ ์‹คํ–‰ํ•ด์„œ Docker ๋ช…๋ น์„ ์ด์šฉํ•ด์„œ ํ™•์ธํ•œ๋‹ค. ํ•ด๋‹น ์˜ˆ์‹œ์—์„œ๋Š” hello-world ์ด๋ฏธ์ง€๋ฅผ ๋ฐ›์•„์„œ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ƒ์„ฑ๋˜๋Š”์ง€ ํ™•์ธํ–ˆ๋‹ค. Windows ํ™˜๊ฒฝ์— Docker ์„ค์น˜๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

๋Œ“๊ธ€