본문 바로가기
Study/DevOps

[Docker] 도커 설치하기

by DevJaewoo 2022. 9. 8.
반응형

Docker LOGO

Intro

이번 시간에는 이전 글에 이어 Docker를 설치하는 방법에 대해 알아보도록 하자.

 

[Docker] Docker는 무엇이고, 왜 사용해야 할까?

Docker는 무엇이고, 왜 사용해야 할까? 요즘 개발 공부를 하면서 개발 관련 프로그램을 설치할 일이 많아졌다. 근데 다른 블로그나 설치 및 사용 튜토리얼들을 보면 Install on Docker, docker pull처럼 Dock

devjaewoo.tistory.com


Docker 설치

Docker는 리눅스 기반에서 돌아가기 때문에, Windows 환경에 Docker를 설치하려면 WSL (Windows Subsystem for Linux)를 통해 리눅스를 실행하고, 그 리눅스를 기반으로 Docker를 설치해야 한다.

Docker를 설치하면 기본적으로 WSL 세팅까지 자동으로 해준다.

 

Docker 홈페이지에서 Windows용 설치 파일을 다운로드 받고 실행하자.

 

Home - Docker

Learn how Atomist will help Docker meet the challenge of securing secure software supply chains for development teams.

www.docker.com

Docker 홈페이지
Download Docker Desktop 버튼을 누르면 된다.
Docker 설치 설정
기본 설정으로 두고 넘어가자.
동의 화면
약관에 동의해야 사용할 수 있다.

설치가 완료되면 Docker에서 WSL을 자동으로 설정하고 서비스를 실행해준다.

도커 프로그램 화면

 

Docker 테스트용 이미지를 실행시켜 설치가 잘 됐는지 테스트해보자.

docker run hello-world

 

아래와 같은 로그가 뜨면 된다.

 

C:\Users\Administrator>docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:7d246653d0511db2a6b2e0436cfd0e52ac8c066000264b3ce63331ac66dca625
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/

WSL 설치

Docker에서 기본으로 제공해주는 WSL이 아닌 다른 OS를 사용하고 싶을 수도 있다.

다른 OS는 별도로 설치해줘야 하는데, 아래의 명령어를 통해 설치되어 있는 OS들을 확인할 수 있다.

wsl -l -v

 

웬만하면 Docker 밖에 없을 것이다. 그럼 이제 원하는 OS를 직접 설치해보자. 난 Ubuntu로 설치해볼 생각이다.

C:\Users\Administrator>wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop         Running         2
  docker-desktop-data    Running         2

 

Microsoft Store에 들어가서 Ubuntu라고 검색하면 아래와 같이 다양한 버전의 우분투가 검색된다.

원하는 버전의 OS를 설치하고 실행시켜주자. 난 22.04 LTS로 설치했다.

Microsoft Store Ubuntu

 

Ubuntu 설치
열기 버튼을 누르면 설치가 시작된다.

실행하면 아래와 같이 설치 화면이 뜨는데, 이 때 Unpacking the distro를 클릭해 로그를 봐야 한다.

아래와 같이 Installing 로그만 뜨면 설치가 정상적으로 되지만, 만약 설정에 문제가 있으면 로그 하나 띄워놓고 그대로 멈춰있는다.

때문에 로그 창을 안열어두면 이게 설치가 잘 되고 있는건지 멈춰있는건지 알 수가 없다. 

Ubuntu 설치 진행

 

설치가 잘 진행되고 있다면 아래와 같은 창이 뜰 것이다. 언어만 영어로 세팅하고 나머지는 기본값으로 진행해도 된다.

언어 설정


WSL 변경

WSL 설치가 완료되고 이전의 명령을 다시 실행하면 설치한 WSL이 뜨는 것을 확인할 수 있다.

C:\Users\Administrator>wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop         Running         2
  Ubuntu-22.04           Running         2
  docker-desktop-data    Running         2

 

[Docker Settings] - [Resources] - [WSL Integration] 에서 사용하고자 하는 OS를 켜주면 Docker를 실행할 기본 WSL을 변경할 수 있다.

Docker default WSL 선택


참고자료

반응형