You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 27 Next »

목차


Docker-compose.yml 파일 작성

deploy/docker-compose.yml
version: '3'

services:
  spring-demo:
	container-name: spring-demo
    image: sooabia/spring-demo:1.0
    restart: always
    ports:
     - '80:8080'
    links:
      - redis
  redis:
    container_name: redis
    image: redis 
    ports:
      - "6379:6379"
    volumes:
      - ./redis:/data/redis
    restart: always 


Redis Volume 폴더 생성

## redis volume을 위한 폴더를 생성합니다.
[root@workspace-vm deploy]# mkdir ./redis

멀티 컨테이너 실행

## Docker compose로 멀티 컨테이너를 실행합니다.
[root@workspace-vm deploy]# docker-compose up -d
Creating network "deploy_default" with the default driver
Creating redis ... done
Creating spring-demo ... done
[root@workspace-vm deploy]# 
[root@workspace-vm deploy]# docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                    NAMES
fc98d294e435        sooabia/spring-demo:1.0   "java -jar /app.jar"     8 seconds ago       Up 6 seconds        0.0.0.0:80->8080/tcp     spring-demo
9ebfffd30318        redis                      "docker-entrypoint.s   9 seconds ago       Up 7 seconds        0.0.0.0:6379->6379/tcp   redis
[root@workspace-vm deploy]# 

어플리케이션 동작 확인

## 멀티 컨테이너 어플리케이션을 실행합니다.
[root@workspace-vm deploy]# curl -XPOST http://localhost/link -H "Content-Type: application/json" -d "{\"link\":\"http://wiki.iisanse.com\"}"
{"shortenedLink":"MrzIHZ"}
## Docker compose 멀티 컨테이너를 정리 합니다.
[root@workspace-vm deploy]# docker-compose down
Stopping spring-demo ... done
Stopping redis        ... done
Removing spring-demo ... done
Removing redis        ... done
Removing network deploy_default
[root@workspace-vm deploy]# 
[root@workspace-vm deploy]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@workspace-vm deploy]# 





  • No labels