2024. 12. 3. 15:34ㆍTIL
✔오늘 배운 중요한 🔑 point
- 내 프로젝트를 AWS를 이용하여 배포할때 동일한 동작을 보장받기 위해서 DOCKER를 사용한다.
- WSL2를 설치하고 Linux용 Windows 하위 시스템을 켜야 하는 이유는 Docker의 원활한 동작과 퍼포먼스 최적화를 위함이다.
- Docker Desktop은 Docker 환경을 쉽게 설정하고 관리할 수 있는 도구이다. WSL2와의 통합으로 Linux 환경을 설정하지 않아도 Docker의 모든 기능을 사용할 수 있다.
🎯 오늘 배운 내용
Docker를 사용하는 이유?
직전 프로젝트에서는 간단하게 Planner 사이트를 만들고 로컬 서버에서만 구동을 하였는데 이번 프로젝트는 AWS를 이용하여 서버를 배포할 생각이어서 Docker를 사용하기로 하였다.
WSL2 설치
Docker는 Linux 컨테이너를 기반으로 작동하기 때문에 Window 운영체제에서 Docker를 사용하기 위해 Linux 커널이 필요한데 WSL2가 그 역할을 수행한다.
WSL2를 설치하기 전 간단한 세팅이 필요하다.
(제어판- 프로그램 기능 - windows 기능 켜기/끄기) Linux용 Windows 하위 시스템 체크
cmd 관리자 권한으로 실행
wsl --install
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --update
리눅스 배포판인 Ubuntu 설치
WSL2에서 설치할 수 있는 Ubuntu를 이용하면 Docker와 완벽하게 호환이 가능하면서 사용하기 아주 쉬운 인터페이스를 가지고 있기 때문에 사용하기 편리하다.
https://apps.microsoft.com/detail/9pn20msr04dw?gl=KR&hl=ko-kr
Ubuntu 22.04.5 LTS - Windows에서 무료 다운로드 및 설치 | Microsoft Store
Install a complete Ubuntu terminal environment in minutes with Windows Subsystem for Linux (WSL). Develop cross-platform applications, improve your data science or web development workflows and manage IT infrastructure without leaving Windows. Key features
apps.microsoft.com
프롬프트 창에서 직접 설치도 가능하다.
시스템을 다시 시작해야만 한다!!
시스템을 다시 시작하고 ubuntu를 실행하면 user이름 password를 입력하라고 나온다.
Docker 설치
Docker 필수 패키지 설치
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
Docker 공식 GPG키 추가
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Docker 저장소 추가
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Docker 설치
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
docker --version을 입력했을때 버전이 잘 나온다면 설치가 완료된것이다.
Docker Desktop 설치
WSL2 기반의 Docker를 간편하게 사용하기 위해서 Docker Desktop을 설치한다.
https://docs.docker.com/desktop/setup/install/windows-install/
Windows
Get started with Docker for Windows. This guide covers system requirements, where to download, and instructions on how to install and update.
docs.docker.com
WSL2를 활성화하기 위해서 Setting-Resources-WSL Integration으로 이동
Ubuntu 활성화 후 Apply& restart
이제 Docker 설치 및 세팅이 완료되었다.
🤔 어떻게 활용할까?
Docker Compose를 사용해 처음부터 개발환경 구성하여 개발 환경과 배포 환경이 일치하게 하여 환경 설정 오류를 최소화 할 수 있게 되었다.
📓 오늘의 한줄
"Hardships often prepare ordinary people for an extraordinary destiny."
- C.S. Lewis -
'TIL' 카테고리의 다른 글
공공API 사용 (1) | 2024.12.05 |
---|---|
공공데이터 활용 프로젝트 (0) | 2024.12.04 |
개인프로젝트 API와 연결할 간단한 웹페이지 만들기(4)- 완성 (1) | 2024.11.30 |
개인프로젝트 API와 연결할 간단한 웹페이지 만들기(3)-일정 작성하기 페이지 (2) | 2024.11.29 |
개인프로젝트 API와 연결할 간단한 웹페이지 만들기(2) -메인페이지 (2) | 2024.11.28 |