목차
도커 Container란?
컨테이너는 코드와 모든 종속성을 패키징하여, 애플리케이션이 다양한 컴퓨팅 환경에서도 빠르고 신뢰성 있게 실행될 수 있게 만드는 표준 소프트웨어 단위입니다. Docker 컨테이너 이미지는 애플리케이션을 실행하는 데 필요한 모든 것(코드, 런타임, 시스템 도구, 시스템 라이브러리 및 설정)을 포함하는 가벼우면서 독립적인, 실행 가능한 소프트웨어 패키지입니다.
컨테이너 이미지는 런타임에 컨테이너가 되며, Docker 컨테이너의 경우 Docker Engine에서 실행될 때 컨테이너가 됩니다. 리눅스 및 윈도우 기반 애플리케이션 모두에 사용할 수 있는 컨테이너화된 소프트웨어는 인프라에 상관없이 항상 동일하게 실행됩니다. 컨테이너는 소프트웨어를 그 환경으로부터 격리시켜, 예를 들어 개발과 스테이징 환경 사이의 차이에도 불구하고 일관되게 작동하도록 보장합니다.
Docker Engine에서 실행되는 Docker 컨테이너는 다음과 같은 특징을 가집니다.
- 표준화: Docker는 컨테이너에 대한 업계 표준을 만들어, 어디서나 포터블하게 할 수 있습니다.
- 경량화: 컨테이너는 기계의 OS 시스템 커널을 공유하므로, 애플리케이션 당 OS가 필요하지 않게 됩니다. 이는 서버 효율성을 높이고 서버 및 라이선스 비용을 줄입니다.
- 보안: 애플리케이션은 컨테이너 안에서 더 안전하며, Docker는 업계에서 가장 강력한 기본 격리 기능을 제공합니다.
Docker 컨테이너는 애플리케이션을 더 휴대성 있고, 경량화하며, 보안적으로 실행할 수 있게 해주는 기술입니다. 이를 통해 다양한 환경에서도 일관된 방식으로 소프트웨어를 실행할 수 있습니다.
도커 Compose란?
Docker Compose는 여러 컨테이너로 구성된 애플리케이션을 정의하고 실행하기 위한 도구입니다. 개발과 배포 과정을 간소화하고 효율적으로 만들어주는 열쇠와 같은 역할을 합니다.
간단히 말해서, Compose는 당신의 애플리케이션을 구성하는 모든 부분(서비스, 네트워크, 볼륨 등)을 하나의 YAML 파일에 명시하게 해주어, 관리를 용이하게 해줍니다. 그리고 단 한 번의 명령으로 이 파일에 정의된 모든 서비스를 생성하고 시작할 수 있습니다.
Compose는 생산, 스테이징, 개발, 테스트 환경 및 CI 워크플로우 등 모든 환경에서 작동합니다. 또한, 애플리케이션의 전체 생명 주기를 관리하는 명령어들을 제공합니다.
- 서비스 시작, 정지, 재구축
- 실행 중인 서비스의 상태 보기
- 실행 중인 서비스의 로그 출력 스트리밍
- 서비스에서 일회성 명령 실행
Docker Compose는 애플리케이션의 모든 구성 요소를 쉽게 관리할 수 있게 해주어, 복잡한 작업을 단순화시켜 줍니다.
도커 Compose 설치 방법
상세 설치 방법은 링크를 참조하시면 됩니다.(https://docs.docker.com/compose/install/standalone/)
1. 아래와 같이 서버에서 설치 파일을 가져와서 설치 합니다.
sudo curl -SL https://github.com/docker/compose/releases/download/v2.24.6/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
아래와 같이 정상 설치됨을 알 수 있습니다.
ubuntu@ip-172-31-4-29:/usr/local/bin$ ls
docker-compose
2. 파일에 실행 권한(x)을 줍니다.
sudo chmod +x /usr/local/bin/docker-compose
3. 실행이 되는지 확인합니다.
docker-compose
ubuntu@ip-172-31-4-29:/usr/local/bin$ docker-compose
Usage: docker compose [OPTIONS] COMMAND
Define and run multi-container applications with Docker
Options:
--ansi string Control when to print ANSI control characters
("never"|"always"|"auto") (default "auto")
--compatibility Run compose in backward compatibility mode
--dry-run Execute command in dry run mode
--env-file stringArray Specify an alternate environment file
-f, --file stringArray Compose configuration files
--parallel int Control max parallelism, -1 for unlimited (default -1)
--profile stringArray Specify a profile to enable
--progress string Set type of progress output (auto, tty, plain, quiet)
(default "auto")
--project-directory string Specify an alternate working directory
(default: the path of the, first specified, Compose file)
-p, --project-name string Project name
Commands:
attach Attach local standard input, output, and error streams to a service's running container
build Build or rebuild services
config Parse, resolve and render compose file in canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service
down Stop and remove containers, networks
events Receive real time events from containers
exec Execute a command in a running container
images List images used by the created containers
kill Force stop service containers
logs View output from containers
ls List running compose projects
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart service containers
rm Removes stopped service containers
run Run a one-off command on a service
scale Scale services
start Start services
stats Display a live stream of container(s) resource usage statistics
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker Compose version information
wait Block until the first service container stops
watch Watch build context for service and rebuild/refresh containers when files are updated
'웹관련프로그래밍(web programming) > Docker(도커)' 카테고리의 다른 글
[도커] apache 웹서버 설치 및 동작(Web server, Docker) (1) | 2024.03.27 |
---|---|
[도커] 컨테이너 실행 및 종료, 백그라운드 동작 (start, run, Docker, Container, background) (1) | 2024.03.25 |
[도커] Docker Image와 Container란?(이미지, 컨테이너) (1) | 2024.03.25 |
[Docker] 도커 로그인, 로그아웃, 이미지 다운로드(Login, Logout, Image, ID, Password) (1) | 2024.03.13 |