요약
# 환경 설정 파일 생성
cd /wisoft/database/mysql
mkdir dev && cd dev
vi .env >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DB_PORT=18880
DB_ROOT_PASSWORD=rootpassword
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<EOF
cd /wisoft/database/mysql/dev
vi docker-compose.yml >>>>>>>>>>>
version: '3' # version 2.7 이후부터 버전 작성 안해도 됨
services:
mysql:
image: mysql:8.0
container_name: mysql-container-dev
restart: always
ports:
- "${DB_PORT}:3306"
environment:
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
- TZ=Asia/Seoul
command:
- --character-set-server=utf8mb4
volumes:
- ./db/mysql/data:/var/lib/mysql
- ./db/conf.d:/wisoft/database/mysql/dev/conf.d
- ./backup:/wisoft/database/mysql/dev/backup
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<EOF
# 컨테이너 실행 [-d: 백그라운드 실행 옵션]
docker compose up -d
# 컨테이너 실행 결과 확인
docker ps
# 기타 Docker 명령어
# 컨테이너 중지
docker stop mysql-container-dev
# 컨테이너 삭제
docker rm mysql-container-dev
# 이미지 삭제
docker rmi mysql:8.0