IT STUDY LOG

[Docker] 00. Before You Learn 본문

devops bootcamp 4/클라우드 서비스 운영

[Docker] 00. Before You Learn

roheerumi 2023. 4. 11. 13:13

# 학습 목표

  • 컨테이너 기술이 무엇인지, Docker가 왜 필요한지 알 수 있다.
  • 컨테이너와 이미지, 레지스트리가 무엇인지 이해할 수 있다.
  • 대표적인 레지스트리인 Docker Hub에서 이미지를 검색하고, 사용할 수 있다.
  • 한 개의 이미지를 이용해서 컨테이너를 구축할 수 있다.
  • 두 개 이상의 이미지를 이용해서 컨테이너를 구축하고 서로가 어떻게 연결되는 지 알 수 있다.
  • Docker CLI에서 명령어를 사용해서 이미지를 생성/수정/배포하고, 컨테이너를 생성/삭제할 수 있다.
  • Dockerfile을 이용해 이미지를 생성할 수 있다.
  • 애플리케이션을 컨테이너화할 수 있다.

 


# 학습 내용

Docker 설치

MacOS 유저용 Docker Desktop 설치 방법

- Install Docker Desktop on Mac

 

Install Docker Desktop on Mac

 

docs.docker.com

- MacOS의 경우 Apple Chip(M1)/ Intel Chip 버전이 따로 존재하므로 주의해서 설치 과정 진행

 

Ubuntu 유저용 Docker Engine 설치 방법

- Install Docker Engine on Ubuntu

 

Install Docker Engine on Ubuntu

 

docs.docker.com

- Docker Engine의 설치 후 Docker Compose도 설치

- 모든 명령어 앞에 sudo 명령어를 붙여 설치

 

1. 오래된 Docker 버전 삭제

$ sudo apt-get remove docker docker-engine docker.io containerd runc

 

2. apt repository 사용 세팅

- apt 패키지 업데이트 후 apt가 레파지토리를 사용할 때 https 통신이 가능하도록 허용

 $ sudo apt-get update
 $ sudo apt-get install \
    ca-certificates \
    curl \
    gnupg

- 도커의 공식 GPG키 등록

$ sudo mkdir -m 0755 -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

- 레파지토리 설정

$ echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

 

3. Docker Engine 설치

$ sudo apt-get update

- 최신 버전 Docker Engine, containerd, Docker Compose 설치

$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

- hello-world 이미지 기동으로 설치 확인

$ sudo docker run hello-world

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/

 

Docker 정상 설치 확인

$ docker --version
Docker version 23.0.3, build 3e7cbfd

 

Comments