[关闭]
@zslzxc 2018-03-09T03:33:07.000000Z 字数 1818 阅读 914

Mysql 链接 容器中的Mysql

docker mysql


查看网络链接列表

  1. sudo docker network ls
  2. NETWORK ID NAME DRIVER SCOPE
  3. cbd7bde63282 bridge bridge local
  4. f70d523c2652 dockeropenrestylor_default bridge local
  5. 57e0e94ae5fc host host local
  6. d1e4fa5e9aba none null local
  7. 7f35dcbe0211 pcsoftdocker_default bridge local
  8. 0778e8ee2a73 wordpress_default bridge local

查看容器网络详情

  1. sudo docker network inspect pcsoftdocker_default
  2. [
  3. {
  4. "Name": "pcsoftdocker_default",
  5. "Id": "7f35dcbe0211ef761f60d8a907993695866068e4bf6d8e81733d60dd00d9a709",
  6. "Created": "2018-03-07T16:56:44.620498952+08:00",
  7. "Scope": "local",
  8. "Driver": "bridge",
  9. "EnableIPv6": false,
  10. "IPAM": {
  11. "Driver": "default",
  12. "Options": null,
  13. "Config": [
  14. {
  15. "Subnet": "172.20.0.0/16",
  16. "Gateway": "172.20.0.1"
  17. }
  18. ]
  19. },
  20. "Internal": false,
  21. "Attachable": true,
  22. "Ingress": false,
  23. "ConfigFrom": {
  24. "Network": ""
  25. },
  26. "ConfigOnly": false,
  27. "Containers": {
  28. "2da2d11568499a4795617d8753f7f3200a8fb67392048ae3413d23aa283cf4c0": {
  29. "Name": "pcsoftdocker_pcsoft_1",
  30. "EndpointID": "7f4f7a2570c3308c47f4dabba95b151cfbff76d615495de3488517ba5e611078",
  31. "MacAddress": "02:42:ac:14:00:02",
  32. "IPv4Address": "172.20.0.2/16",
  33. "IPv6Address": ""
  34. },
  35. "eb56aa4c97e924474ba912962ae517ad970d73e0e101756194cca2214b96a9e6": {
  36. "Name": "pcsoftdocker_db_1",
  37. "EndpointID": "e4cd75d3829d48bd8ae7cdc3a4775c9c7c4b8672859e8585245dcaff18cd50c6",
  38. "MacAddress": "02:42:ac:14:00:03",
  39. "IPv4Address": "172.20.0.3/16",
  40. "IPv6Address": ""
  41. }
  42. },
  43. "Options": {},
  44. "Labels": {
  45. "com.docker.compose.network": "default",
  46. "com.docker.compose.project": "pcsoftdocker"
  47. }
  48. }
  49. ]

Mysql远程链接

  1. amor@amor-PC:~$ mysql -h 172.20.0.3 -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 2
  5. Server version: 5.7.21 MySQL Community Server (GPL)
  6. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注