도커를 쓰는 이유?
프로그램 실행에 필요한 환경을 통일하기 위해
컨테이너란?
코드, 종속성 등을 패키지화해서 프로그램이 어디서나 안정적으로 빠르게 실행될 수 있도록 하는 소프트웨어 단위. 컨테이너화된 소프트웨어는 인프라에 관계없이 항상 동일하게 실행되고 어떤 개발과 스테이징의 차이에서도 균일한 작동이 보장된다.
도커 이미지(컨테이너 이미지)란?
코드, 런타임, 라이브러리 등 프로그램을 실행하는 데 필요한 모든 것을 포함하는 소프트웨어 패키지. 컨테이너는 이미지의 인스턴스라고 볼 수 있다.
도커 vs VM
VM은 서버를 논리적으로 분할해서 독립적으로 이용 가능한 가상 환경의 서버
하이퍼바이저는 호스트 시스템에서 여러 게스트OS를 이용할 수 있도록 하드웨어 가상화, VM 모니터링 등을 담당하는 중간 관리 소프트웨어
하이퍼바이저 기반 가상화 기술을 토대로 도커가 출현
기존의 VM은 호스트 시스템 내에 가상 머신 실행, 자원 할당, 게스트 OS 부팅 등의 과정을 거쳐야만 했으나(오버헤드 큼) 도커는 호스트 시스템에 이미지가 바로 띄워지므로 훨씬 가볍게 돌아간다
이것을 가능하게 한 것은 리눅스 커널 기능인 Cgroup과 네임스페이스
Cgroup은 프로세스 그룹의 시스템 리소스 사용량을 관리하고 네임스페이스는 단일 시스템 내에서 프로세스를 격리할 수 있는 가상화 기술이다
도커의 작동 Flow
터미널을 통해 docker 명령어를 입력하면 도커 클라이언트 - 도커 서버(데몬) - 이미지 캐시 확인 - 캐시에 이미지가 없다면 docker hub에서 이미지를 가져옴
도커 이미지 = 시작 명령어 + 파일 스냅샷
docker run <image> 를 입력하면 실행에 필요한 모든 프로세스가 진행
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:926fac19d22aa2d60f1a276b66a20eb765fbeea2db5dbdaafeb456ad8ce81598
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/
'웹 > Docker' 카테고리의 다른 글
[Docker]Travis CI, EB를 이용한 배포 (0) | 2023.07.25 |
---|---|
[Docker]개발 환경 vs. 운영 환경 (0) | 2023.07.24 |
[Docker]COPY, Volume, Compose (0) | 2023.07.23 |
[Docker]이미지 (0) | 2023.07.23 |
댓글