본문 바로가기
IT/Docker

[Docker] Docker Engine

by 깅지수 2022. 5. 4.

 

* Registry : container에서 필요한 image 저장소

=> local에서 직접 구축할 수도 있고 서비스를 이용할 수도 있음

(대표적인 SaaS 형태 서비스 : Docker hub)

 

** (VM과는 달리) container는 (start/stop 개념은 있지만) 컴퓨터를 "키고 끈다"라는 개념이 존재하지 X

 

Container Image

  • docker image 형태
[Registry]/[Repository]/[IMAGE]:[TAG] 
docker.io/library/hello-world:latest

#registry는 생략 가능

(** image를 지정할 때, tag를 지정하지 않으면 자동으로 'latest'가 tagging됨)

 

  • docker image 실행
docker run hello-world

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(=stdout/stderr) to the Docker client, which sent it
    to your terminal.

 

  • docker 실행 기록 확인
docker ps			#현재 실행중인 container 목록
docker ps -a			#실행 했던 container 목록

 

  • container 삭제
docker rm [NAMES]
docker rm [CONTAINER ID]

 

  • image 삭제
docekr rmi [IMAGE]
docekr rmi [IMAGE ID]

 

Lifecycle

create -> start -> (pause/unpause) -> (kill) -> stop -> rm
#위 과정을 한번에 실행
run ---------->

* container는 application이 종료되면 자동으로 함께 종료(stop)됨

(container는 application 실행을 위해 존재하기 때문)

 

 

Docker Option

  • -i: (interactive) Keep STDIN open even if not attached (=docker client가 docker daemon에게 STDIN 전송)
  • -t: (tty) Terminal 할당
  • -d: Detach (background에서 계속적으로 실행 *image에 따라 가능/불가능 나뉨)

* -i 옵션만 사용하게 된다면 실행유무 구분이 어렵

  ---> -t 옵션을 같이 부여해서 우리가 알고있는 일반적인 형태로 나타냄

* -it 옵션은 Shell을 실행하는 이미지에서 사용 (ex. centos, ubuntu ... )
* -d 옵션 application이 계속적으로 실행되어야 할 때 (ex. httpd ... )

 

 

Base Image - 리눅스 배포판 이름으로된 이미지 (* 배포되는 image에는 OS 즉, 별도의 Kernel이 존재하지 x)

- ubuntu
- centos
- rocky
- debian
alpine 
- busybox
- amazonlinux
- oraclelinux
...

'IT > Docker' 카테고리의 다른 글

[Docker] Docker Compose  (0) 2022.05.11
[Docker] Docker Image Build  (0) 2022.05.11
[Docker] Docker의 Volume과 Network  (0) 2022.05.09
[Docker] Docker 관리 및 명령어  (0) 2022.05.04
[Docker] Docker 설치 및 개요  (0) 2022.05.03