Get Docker Mac, Window, Linux 설치
https://docs.docker.com/get-docker/
Get Docker
Download and install Docker on the platform of your choice, including Mac, Linux, or Windows.
docs.docker.com
Docker Guide
https://docs.docker.com/guides/walkthroughs/
Walkthroughs overview
Learn how to build, share, and run applications faster with Docker's 5-minute hands-on walkthroughs
docs.docker.com
Docker Hub
Docker Hub( http://hub.docker.com) 에서 이미지를 공유하고 저장할 수 있습니다. open_in_new). Docker Hub에는 로컬에서 실행할 수 있는 개발자가 만든 100,000개 이상의 이미지가 있습니다. Docker Hub 이미지를 검색하고 Docker Desktop에서 직접 실행할 수 있습니다.
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
다중 컨테이너 애플리케이션 실행
이미 컨테이너를 실행하려면 어떻게 해야 합니까? 연습에서는 각 컨테이너를 개별적으로 시작해야 한다는 점을 배웠습니다. 도구가 단일 명령으로 여러 컨테이너를 시작할 수 있다면 얼마나 좋을지 상상해 보세요. 그 도구는 Docker Compose입니다.
Docker Compose 예시 코드
https://docs.docker.com/guides/walkthroughs/multi-container-apps/
Run multi-container applications
Learn how to use Docker to run multi-container applications
docs.docker.com
Docker Compose 실행
$ cd /path/to/multi-container-app/
$ docker compose up -d
// 이전 명령에서 -d플래그는 Docker Compose가 분리 모드에서 실행되도록 지시합니다.
Compose Watch 실시간 변경사항 확인
$ docker compose watch
컨테이너 간 데이터 유지
Docker는 로컬 파일 시스템에서 컨테이너의 모든 콘텐츠, 코드 및 데이터를 격리합니다. 컨테이너를 삭제하면 Docker는 해당 컨테이너 내의 모든 콘텐츠를 삭제합니다.

때로는 컨테-이너가 생성하는 데이터를 유지해야 할 수도 있습니다. 이를 위해 볼륨을 사용할 수 있습니다.
예제 코드
https://docs.docker.com/guides/walkthroughs/persist-data/
Persist data between containers
Learn how to persist data between containers
docs.docker.com
컨테이너에서 로컬 폴더에 엑세스
Docker는 로컬 파일 시스템에서 컨테이너의 모든 콘텐츠, 코드 및 데이터를 격리합니다. 기본적으로 컨테이너는 로컬 파일 시스템의 디렉터리에 액세스할 수 없습니다.

때로는 로컬 파일 시스템에서 디렉터리에 액세스하고 싶을 수도 있습니다. 이를 위해 바인드 마운트를 사용할 수 있습니다.
https://docs.docker.com/guides/walkthroughs/access-local-folder/
Access a local folder from a container
Learn how to access a local folder from a container
docs.docker.com
애플리케이션 컨테이너화
https://docs.docker.com/guides/walkthroughs/containerize-your-app/
Containerize your application
Learn how to containerize your application.
docs.docker.com
Dockerfile컨테이너 작업 시 일반적으로 이미지를 정의하는 파일과 compose.yaml이미지 실행 방법을 정의하는 파일을 생성해야 합니다 .
이러한 파일을 생성하는 데 도움이 되는 Docker Desktop에는 다음 docker init명령이 있습니다. 프로젝트 폴더 내의 터미널에서 이 명령을 실행하세요. docker init애플리케이션을 컨테이너화하는 데 필요한 모든 파일을 생성합니다. 이 연습에서는 이것이 어떻게 작동하는지 보여줍니다.
샘플 프로젝트 생성
$ npm i -g express-generator
$ express docker-sample-project --view=ejs
$ cd docker-sample-project
$ npm install
Docker 파일 생성
$ cd /path/to/your/project/
$ docker init
DockerFile
# syntax=docker/dockerfile:1
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/
ARG NODE_VERSION=16.20.1
FROM node:${NODE_VERSION}-alpine
# Use production node environment by default.
ENV NODE_ENV production
WORKDIR /usr/src/app
# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci --omit=dev
# Run the application as a non-root user.
USER node
# Copy the rest of the source files into the image.
COPY . .
# Expose the port that the application listens on.
EXPOSE 3002
# Run the application.
CMD npm start
docker 실행
$ docker compose up -d
docker init 문서
https://docs.docker.com/engine/reference/commandline/init/
docker init
Beta The Docker Init plugin is currently in Beta. Docker recommends that you do not use this in production environments.
docs.docker.com
이미지 게시
https://docs.docker.com/guides/walkthroughs/publish-your-image/
Publish your image
Learn how to publish your image to Docker Hub
docs.docker.com
'Docker > docs' 카테고리의 다른 글
[Docker] [docs] 05. DB 유지 (볼륨) (0) | 2023.12.05 |
---|---|
[Docker] [docs] 04. 애플리케이션 공유, Docker Hub (0) | 2023.12.04 |
[Docker] [docs] 03. 애플리케이션 업데이트, 컨테이너 빌드 (0) | 2023.12.04 |
[Docker] [docs] 02. 애플리케이션 컨테이너화 (0) | 2023.11.30 |
[Docker] [docs] 01. get-stated (0) | 2023.11.30 |