I. Pull and Run a official image

1. Pull a MySQL docker image

docker pull mysql/mysql-server:5.7

docker images
    REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
    mysql/mysql-server   5.7                 c8c8ef4f3c81        8 weeks ago         310MB

2. Run a MySQL docker container

# -d,       as daemon mode
# -name,    naming the container
# -p,       mapping the network port
# -e,       assign an environment variable

docker run --name mysql57 -d -p 3306:3306 mysql/mysql-server:5.7
    241fd5e41ae17791df7cf43deddd9aca70dadb2c0e20f2ca0c4b27fa214db1da

docker ps -a
    CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                   PORTS                               NAMES
    56b561541f60        mysql/mysql-server:5.7   "/entrypoint.sh mysq…"   2 minutes ago       Up 2 minutes (healthy)   0.0.0.0:3306->3306/tcp, 33060/tcp   mysql57

# note1: wait until the STATUS to be "healthy", before using it.
# note2: note down the random mysql root password
docker logs mysql57 2>&1 | grep GENERATED
    [Entrypoint] GENERATED ROOT PASSWORD: @pz3dzedcogc0cEvkuq0wqaqEz(

3. Change temporary mysql root password

docker exec -it mysql57 mysql -uroot -p
    Enter password: # enter above temp password

mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql'; 
    Query OK, 0 rows affected (0.00 sec)

4. Connect to MySQL container OS

docker exec -it mysql57 bash 
bash-4.2# ls /var/lib/mysql
auto.cnf    ca.pem	     client-key.pem  ib_logfile0  ibdata1  mysql       mysql.sock.lock	   private_key.pem  server-cert.pem  sys
ca-key.pem  client-cert.pem  ib_buffer_pool  ib_logfile1  ibtmp1   mysql.sock  performance_schema  public_key.pem   server-key.pem

5. Stop the MySQL container

docker stop mysql57

docker ps -a
    CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                    PORTS               NAMES
    56b561541f60        mysql/mysql-server:5.7   "/entrypoint.sh mysq…"   12 minutes ago      Exited (0) 1 second ago                       mysql57

6. Other command for container

# start container
docker start mysql57

# restart container
docker restart mysql57

# delete container
docker rm mysql57

More customized MySQL Installation for Docker