-
Notifications
You must be signed in to change notification settings - Fork 44
NOTE20190915
Somkiat Puisungnoen edited this page Sep 15, 2019
·
5 revisions
docker container run -d --name db \
-e MYSQL_ROOT_PASSWORD=pass \
-e MYSQL_DATABASE=first \
-e MYSQL_USER=name \
-e MYSQL_PASSWORD=pass \
mysql:8
docker container exec -it db bash
mysql -uname -ppass
show databases;
use first
show tables;
USE first;
CREATE TABLE USER (
id INT(11),
name char(60)
) ENGINE=INNODB;
INSERT INTO USER VALUES(1, 'Sample name 01');
INSERT INTO USER VALUES(2, 'Sample name 02');
INSERT INTO USER VALUES(3, 'Sample name 03');
FROM mysql:8
COPY data.sql /docker-entrypoint-initdb.d/
docker image build -t mydb:1.0.0 -f Dockerfile_db .
version: '3.7'
services:
first:
build:
context: .
dockerfile: Dockerfile
ports:
- "9999:80"
mydb:
build:
context: .
dockerfile: Dockerfile_db
environment:
- MYSQL_ROOT_PASSWORD=pass
- MYSQL_DATABASE=first
- MYSQL_USER=name
- MYSQL_PASSWORD=pass
Run
docker-compose build
docker-compose up -d
docker-compose ps
docker-compose logs --follow