본문 바로가기

PROGRAMMING/CI&CD

[Docker] 도커 시작하기3 - CLI Command

도커 이미지 다운로드

Docker Hub

 

Docker Hub Container Image Library | App Containerization

Build and Ship any Application Anywhere Docker Hub is the world's easiest way to create, manage, and deliver your team's container applications. Create your account Signing up for Docker is fast and free. Continue with GoogleContinue with GitHubContinue wi

hub.docker.com

 

예제 image

https://hub.docker.com/_/httpd

 

httpd - Official Image | Docker Hub

Quick reference Supported tags and respective Dockerfile links 2.4.58, 2.4, 2, latest, 2.4.58-bookworm, 2.4-bookworm, 2-bookworm, bookworm 2.4.58-alpine, 2.4-alpine, 2-alpine, alpine, 2.4.58-alpine3.19, 2.4-alpine3.19, 2-alpine3.19, alpine3.19 Quick refere

hub.docker.com

docker hub httpd

Docker Official Image 

도커에서 인증한 믿고 사용해도 되는 official한 이미지

 

터미널에서 docker pull httpd 명령어를 실행하면 image를 다운 받는다. 

 

Docker CLI 명령어 관련 공식 문서

Docker CLI Command Reference 

 

Use the Docker command line

Docker's CLI command description and usage

docs.docker.com

 

Docker CLI Command example

 

도커 이미지 다운로드

> docker pull [image]

 

다운받은 도커 이미지 실행 및 컨테이너 생성

> docker run [image]

 

컨테이너 이름을 지정해서 생성

> docker run --name [container name][image]

 

도커 컨테이너 상태 및 정보 체크 

> docker ps

> -a 옵션을 주면 중지 상태인 컨테이너도 확인 할 수 있다.

 

도커 컨테이너 중지

> docker stop [container id or name]

> 중지 상태이기 때문에 docker ps -a 옵션으로 확인 할 수 있다.

 

도커 컨테이너 실행

> docker start [container id or name]

 

도커 컨테이너 로그 확인

> docker logs [container id or name]

 

실시간으로 도커 컨테이너 로그 출력

> docker logs -f [container id or name]

 

도커 컨테이너 삭제

> docker rm [container id or name]

> 현재 실행중인 컨테이너는 삭제 할 수 없음으로 에러가 출력됨

> stop을 먼저 실행 그 뒤 rm 실행

> 위에 과정이 귀찮다면 docker rm --force [container id or name] 실행

 

도커 이미지 삭제

> docker rmi [image name]

> 삭제 후 docker images로 확인하면 보이지 않음