===========================================
MYSQL
===========================================
my-secret-pw
de28ac9eca6e
##도커 다운로드
https://www.docker.com/products/docker-desktop/
sudo apt install docker-ce
##mysql 공식 이미지 받기
docker pull mysql
##mysql 이미지를 도커컨테이너로 실행함
docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=my-secret-pw -d -p 3306:3306 mysql:latest
##실행하기
docker exec -it mysql-container mysql -uroot -p
docker cp /home/ bccfab6289eb:/var/lib/mysql-files/backup.sql
docker exec -it mysql-container bash
docker exec -it mysql-container mysql -uroot -p
##패스워드정보
my-secret-pw
##mysql 접속 성공
show databases;
#
SOURCE /var/lib/mysql-files/backup.sql;
docker exec -i de28ac9eca6e mysql-container -u root -p /var/lib/mysql-files/Dump20241113.sql
docker exec -i mysql-container mysqldump -u root -p --all-databases >/var/lib/mysql-files/backup.sql
mysqldump -u root -p --all-databases > C:\mysql-files/backup.sql
my-secret-pw
==========================================
백엔드
==========================================
docker build -t jarrydms/backend .
docker run -p 8080:8080 jarrydms/backend
docker tag backend jarrydms/backendproject:back-1
docker push jarrydms/backendproject:back-1
EC2
====================================
sudo docker pull jarrydms/backendproject:back-1
sudo docker run -d -p 8080:8080 --name jarrydms/backend jarrydms/backendproject:back-1
====================================
EC2 - MYSQL
====================================
##실행하기
docker exec -it mysql-container2 mysql -uroot -p
docker cp /home/ 47e27c2ea792:/var/lib/mysql-files/backup.sql
docker cp /home/jjhotel_reservation.sql 47e27c2ea792:/var/lib/mysql-files/jjhotle_reservation.sql
docker cp /home/jjhotel_guest.sql 47e27c2ea792:/var/lib/mysql-files/jjhotle_guest.sql
docker cp /home/jjhotel_room.sql 47e27c2ea792:/var/lib/mysql-files/jjhotel_room.sql
SOURCE /var/lib/mysql-files/jjhotle_reservation.sql
SOURCE /var/lib/mysql-files/jjhotel_room.sql
SOURCE /var/lib/mysql-files/jjhotle_guest.sql
스키마 이름
CREATE DATABASE jjhotle
use jjhotel
jjhotel
===========================================
프론트엔드
===========================================
docker build -t frontend .
docker run -p 80:80 frontend
docker start distracted_solomon
localhost:80 리액트 실행확인
docker에 이미지 올리기
태그를 달고
docker build -t frontend .
docker run -p 80:80 frontend
docker tag frontend jarrydms/frontendproject:front-1
docker run -d -p 80:80 --name myfrontend jarrydms/frontendproject:front-1
EC2
==================
sudo docker pull jarrydms/frontendproject:front-1
sudo docker run -d -p 80:80 --name frontend-container jarrydms/frontendproject:front-1
===============================
sudo docker start backend
===============================
네트워크
===============================
docker network create mynetwork
==============================
MYSQL-EC2(도커) MYSQL 네트워크
==============================
docker run -d --name mysql-container \
--network mynetwork \
-e MYSQL_ROOT_PASSWORD=1234 \
-p 3306:3306 \
mysql:latest
==============================
백엔드 - EC2 도커 - 네트워크
==============================
docker run -d --name backend-container \
--network mynetwork \
-p 8080:8080 \
-e DB_HOST=mysql-container \
-e DB_PORT=3306 \
-e DB_USER=root \
-e DB_PASSWORD=1234 \
jarrydms/backendproject:back-1
=============================
프론트엔드 - EC2 도커 - 네트워크
=============================
docker run -d --name frontend-container \
--network mynetwork \
-p 80:80 \
-e REACT_APP_API_URL=http://backend-container:8080 \
jarrydms/frontendproject:front-1
=============================
compose
=============================
docker-compose up --build
백엔드 이미지 태그 및 도커허브에 push
==========================
docker tag docker_compose-backend:latest jarrydms/docker_compose:compose-1
docker push jarrydms/docker_compose:compose-1
docker pull jarrydms/docker_compose:compose-1
프론트 이미지 태그 및 도커허브에 push
===========================
docker tag docker_compose-frontend:latest jarrydms/docker_compose:compose-2
docker push jarrydms/docker_compose:compose-2
=====================================
docker exec -it mysql-container3 mysql -uroot -p
'클라우드 > Docker' 카테고리의 다른 글
[DOCKER] EC2 생성 / Nginx 배포 (0) | 2024.11.24 |
---|---|
[docker] 기본개념 및 동작 (2) | 2024.11.20 |
[DB] 1단계 MYSQL & DOCKER 마이그레이션 해보기 (2) | 2024.11.16 |
[docker compose] 리액트+스프링부트 dockercompose 하기 (1) | 2024.11.15 |
[프론트엔드] 리액트 + docker 컨테이너로 이미지 만들기 (0) | 2024.11.14 |