# 拉取Ubuntu镜像
docker pull docker.io/ubuntu:14.04.
# 运行一个容器
docker run --name mysql -p 33:3306 -v /mysql:/var/lib/mysql -it docker.io/ubuntu:14.04.3
-p 映射容器端口3306到本地端口33,-v 映射容器存储/var/lib/mysql到本地/mysql,--name给容器取名,-it进入交互终端。
# 容器内安装mysql-server
root@816bee758633:/# apt-get -y install mysql-server
安装途中会出现
输入mysql "root"用户的密码。
# 开启mysql服务
service mysql start
# 进入mysql
root@816bee758633:/# mysql -u root -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.5.-1ubuntu1 (Ubuntu) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
# 查看存储映射
# 查看端口映射