작업 디렉토리 : ~/compose/wp
docker-compose.yaml
version: "3"
services:
wp-db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: P@ssw0rd
MYSQL_DATABASE: wordpress
MYSQL_USER: wpadm
MYSQL_PASSWORD: P@ssw0rd
volumes:
- wp-db-vol:/var/lib/mysql
networks:
- wp-net
wp-web:
depends_on:
- wp-db
image: wordpress:5-apache
restart: always
environment:
WORDPRESS_DB_HOST: wp-db # 서비스 디스커버리
WORDPRESS_DB_USER: wpadm
WORDPRESS_DB_PASSWORD: P@ssw0rd
WORDPRESS_DB_NAME: wordpress
ports:
- "80:80"
volumes:
- wp-web-vol:/var/www/html
networks:
- wp-net
volumes:
wp-db-vol:
wp-web-vol:
networks:
wp-net:
🌟 서비스 디스커버리 : 자체 내부 DNS 서비스를 실행하여 이름별로 서비스를 라우팅
컨테이너 생성
docker compose up -d
[+] Running 5/5
⠿ Network wp_wp-net Created 0.1s
⠿ Volume "wp_wp-db-vol" Created 0.0s
⠿ Volume "wp_wp-web-vol" Created 0.0s
⠿ Container wp-wp-db-1 Started 0.9s
⠿ Container wp-wp-web-1 Started 2.8s
컨테이너 삭제
docker compose down -v
[+] Running 5/5
⠿ Container wp-wp-web-1 Removed 1.4s
⠿ Container wp-wp-db-1 Removed 1.7s
⠿ Volume wp_wp-web-vol Removed 0.1s
⠿ Network wp_wp-net Removed 0.4s
⠿ Volume wp_wp-db-vol Removed 0.1s
🎈 반드시 -v
옵션을 함께 사용하여 wordpress volume까지 삭제
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ sudo apt -y install unzip
$ unzip awscliv2.zip
$ sudo ./aws/install
$ aws configure
Private
레포지토리로 생성
-> IAM에 의해 관리
유일한 이름
으로 설정
이미지 스캔 : 활성화 (비용 발생)
작업 디렉토리 : ~
$ aws ecr get-login-password --region us-east-1 |
docker login --username AWS --password-stdin [레포지토리 이름]
WARNING! Your password will be stored unencrypted in /home/vagrant/.docker/config.json.
...
Login Succeeded
docker build -t [레포지토리 이름] 📌확인
docker tag [이미지명]:[태그] [레포지토리명]:[태그]
이미지를 AWS 리포지토리로 푸시
docker push [레포지토리명]:[태그]
이름지정 : mycontainer-cluster
네트워킹 : Default (이 실습은 변경하지 않고 진행)
인프라 : Fargate 자동 설정
1단계 : 태스크 정의 및 컨테이너 구성
태스크 정의 패밀리 : pyweb-task2
컨테이너
2단계 : 환경, 스토리지, 모니터링 및 태그 구성
앱 환경 : AWS Fargate
운영체제 : Linux/X86_64
태스크 크기 : .25v CPU, 1GB 메모리 (현재 제일 작은 사이즈로 지정)
태스크 역할 : 없음 (원래 지정해줘야 함)
배포구성
서비스
: 중지 및 다시 시작할 수 있는 장기 실행 컴퓨팅 작업태스크정의
]보안 그룹
미리 설정해서 생성!!cloudwatch에서 로그 그룹 삭제!! (비용 발생)
웹 브라우저에서 태스크 정의 public IP/서비스 포트번호
로 접속