docker를 활용한 react-node 어플케이션 (with mysql)
전체 파일 구조
정말 정말 간단한 mysql과 연결한 react-node web app 입니다.
링크 : https://hub.docker.com/_/mysql
docker pull jung660317/react-node-app-with-mysql
docker exec -it <mysql container name> /bin/bash
mysql -u root -p
테이블의 필드의 이름은 아무거나 상관없지만 하나의 필드만 적용해야 합니다
create database db;
use db;
create table table1(name char(20));
version: '3.1'
services:
mysql:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
container_name: mysql
network_mode: host
environment:
MYSQL_ROOT_PASSWORD: admin
adminer:
image: adminer
restart: always
network_mode: host
ports:
- 8080:8080
react-node-app-with-mysql:
image: jung660317/react-node-app-with-mysql
container_name: react-node-app
restart: always
ports:
- 3000:3000
network_mode: host
docker-compose up -d --build
정상 동작 확인
input 창에 입력한 데이터를 넣어줍니다.
mysql 데이터베이스에 들어간 데이터를 보여줍니다.
mysql 데이터베이스에 들어간 데이터를 모두 삭제합니다.