[Docker] Docker MySql & Postgres
less than 1 minute read
MySQL & Postgres in Docker
# mysql
docker container run \
-p 3306:3306 \
--name mysql1 \
-e MYSQL_ROOT_PASSWORD=1234 \
-d \
-v mysql_data:/var/lib/mysql \
mysql:5.7.19
# mariadb
docker container run \
-p 3306:3306 \
--name mariadb1 \
--network airflownet \
-e MYSQL_ROOT_PASSWORD=1234 \
\-d \
\-v mysql_data:/var/lib/mysql \
mariadb:10.6 \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci
# postgresql
docker container run \
-p 5432:5432 \
--name postgres1 \
-e POSTGRES_PASSWORD=1234 \
-d \
-v psql_data:/var/lib/postgresql/data \
postgres:13.12
DOCKER MYSQL sql dump
# local directory에서 docker container으로 cp (docker cp [file/directory] [container_id:/home])
docker cp emp fad2828c2116:/home
docker cp employees fad2828c2116:/home
# docker을 통해 MySQL 서버에 로그인 (docker exec -it [mysql container_name(id)] bash)
docker exec -it mysql1 bash
# mysql -p
mysql -p
# enter password
1234
# mysql 서버에서 실행
source home/emp/createTable.sql
source home/emp/insertTable.sql
soure home/employees/employees.sql
# employees.sql의 source의 directory 확인!