Docker运行mysql
1.系统环境
CentOS 7
安装过更新
# yum upgrade
2.安装docker 略
查看本地镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql latest 594dc21de8de 3 weeks ago 400.1 MB
docker.io/java latest a001fc27db5a 3 weeks ago 643.2 MB
[root@CentOS ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
启动mysql镜像
[root@CentOS ~]# docker run -d -e MYSQL_ROOT_PASSWORD=admin --name mysql -v /data/mysql/etc:/etc/mysql/conf.d -v /data/mysql/data:/var/lib/mysql -v /etc/localtime:/etc/localtime:ro mysql
[root@CentOS ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3710a80d426d mysql "docker-entrypoint.sh" 2 days ago Up 2 days 3306/tcp mysql