dockerでmysqlを操作2

$ sudo docker pull mysql
$ sudo docker run -it –name test-wolrd-mysql -e MYSQL_ROOT_PASSWORD=mysql -d mysql:latest
sudo docker exec -it test-wolrd-mysql bash -p
mysql -u root -p -h 127.0.0.1

$ tree
.
├── docker-compose.yml
└── mysql
├── DB
│   └── world.sql
├── Dockerfile
└── my.cnf

docker-compose.yml

version: "3"
services:
  mysql:
    build: ./mysql/
    volumes:
      - ./mysql/db:/docker-entrypoint-initdb.d
    image: original_mysql_world
    environment:
      - MYSQL_ROOT_PASSWORD=mysql

world.sql

-- MySQL dump 10.13  Distrib 5.1.51, for pc-linux-gnu (i686)
--
-- Host: 127.0.0.1    Database: world
-- ------------------------------------------------------
-- Server version       5.1.51-debug-log

Dockerfile

FROM mysql

EXPOSE 3306

ADD ./my.cnf /etc/mysql/conf.d/my.cnf

CMD ["mysqld"]

my.cnf

[mysqld]
character-set-server=utf8

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

$ sudo docker-compose build
$ sudo docker-compose up -d
$ sudo docker exec -it mysql_mysql_1 bash -p