美文网首页
Docker[note_05] docker应用部署 使用doc

Docker[note_05] docker应用部署 使用doc

作者: 墨流引 | 来源:发表于2020-03-20 21:35 被阅读0次
docker run -id \
-p 3306:3306 \
--name c_mysql \
-v $PWD/conf:/etc/mysql/conf.d \
-v $PWD/logs:/logs \
-v $PWD/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:8.0
  • -p 端口映射,容器3306映射到宿主机3306
  • -v 数据卷
  • -e MYSQL_ROOT_PASSWORD=123456设置mysql的root默认启动密码
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
e5f80874d980        mysql:8.0           "docker-entrypoint.sh"   6 minutes ago       Up 6 minutes        0.0.0.0:3306->3306/tcp, 33060/tcp   c_mysql

$ docker exec -it c_mysql bash
root@e5f80874d980:/# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>

查看宿主机ip

$ docker-machine ip
192.168.99.101

因为我使用的是windows的docker toolbox所以查看宿主机的ip可以使用 docker-machine ip查看,然后使用MySql Workbench链接一下mysql容器的。

docker_mysql

相关文章

网友评论

      本文标题:Docker[note_05] docker应用部署 使用doc

      本文链接:https://www.haomeiwen.com/subject/erpsyhtx.html