유용한 IT Tool

WSL 2 Docker 설치 방법

Somaz 2023. 4. 26. 20:15
728x90
반응형

Overview

오늘은 Window에서 WSL2 설치 후 Backend로 Docker를 사용하는 방법에 대해서 알아보려고 한다.


Install

먼저 Install Docker Desktop on Windows 를 클릭해서 Windows용 docker desktop을 다운로드 받고 설치한다.

 

 

 

설치하고 docker 를 실행한 후에  Settings  메뉴를 선택한다.

 

설정 화면에서 General  → Use the WSL2 based engine  이 체크되어 있는지 확인한다.

 

 

Resources  → WSL Integration  에서 docker 를 사용할 WSL 을 체크한 후에 Apply & Restart  를 클릭한다.

 

 

이제 WSL 인스턴스를 열고 명령행에서 docker 를 실행한다.

$ docker --version
Docker version 20.10.24, build 297e128

 

 

정상 동작 여부를 확인하기 위해 hello-world 컨테이너를 실행해본다.

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:4e83453afed1b4fa1a3500525091dbfca6ce1e66903fd4c01ff015dbcb1ba33e
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/

somaz@AD01769994:~$ docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED         STATUS                     PORTS     NAMES
14ffa01f53f2   hello-world   "/hello"   9 seconds ago   Exited (0) 8 seconds ago             vibrant_tu

 

docker build 명령어를 사용해 이미지를 build 해본다.

$ docker build -f somaz.Dockerfile -t somaz:1.0 ./
[+] Building 153.9s (18/21)
 => [internal] load .dockerignore                                                                                                                                                      0.1s
 => => transferring context: 289B                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/node:17-alpine                                                                                                                      2.6s
 => [internal] load metadata for docker.io/library/node:17-slim                                                                                                                        2.6s
 => [builder 1/8] FROM docker.io/library/node:17-slim@sha256:a180966357fe14cac9dd6c9cd496ed4d85b8a598cb33482705ecebad646145e3                                                          3.7s
 ...
  => exporting to image                                                                                                                                                                 4.9s
 => => exporting layers                                                                                                                                                                4.9s
 => => writing image sha256:f1c795899d0bdd9d938fc613b7b1222c6da3e56d90c931f23ae1191856d1296f                                                                                           0.0s
 => => naming to docker.io/library/somaz:1.0

 


Reference

Windows Docker 데스크탑 설치

 

 

728x90
반응형

'유용한 IT Tool' 카테고리의 다른 글

VSCode Vim Extension 사용 가이드  (0) 2024.05.17
Openlens / Choco 설치  (0) 2023.04.21
WSL 창 분할 창 닫기 메모  (0) 2023.01.09