標籤:通過 password names contain -name 串連資料庫 mysql 定義 bsp
轉自:http://blog.csdn.net/daocaoren92wq/article/details/68484049
$ docker pull mysql[email protected]:~$ docker pull mysqlUsing default tag: latestlatest: Pulling from library/mysql6d827a3ef358: Pull complete ed0929eb7dfe: Pull complete 03f348dc3b9d: Pull complete fd337761ca76: Pull complete 7e6cc16d464a: Pull complete ca3d380bc018: Pull complete 3fe11378d5c0: Pull complete 2b5dfd325645: Pull complete b54281d17fbe: Pull complete 9a5cfd2d8db6: Pull complete a371b9bf0e19: Pull complete Digest: sha256:b39e58483853ecd03160f9bfdc8d3ecb0be9071fdbbe5484d6a115677b62c84eStatus: Downloaded newer image for mysql:latest[email protected]:~$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql_ubuntu_0.1 latest c3fb44aa3b0f 10 hours ago 130 MBmysql latest 5faba1a71ec4 8 days ago 407 MBubuntu latest 0ef2e08ed3fa 4 weeks ago 130 MB
- $ docker run –name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
–name :自訂容器名
some-MySQL:容器名字
-e :設定密碼
my-secret-pw:資料庫密碼
-d : 後台執行
-p 連接埠號碼映射
[email protected]:~$ docker run -p 53306:3306 --name testmysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql6a38e59ef95d1a3f63a12d9c6c2ae20cf782001f25641f5159812e2a707f3f1d[email protected]:~$ docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES6a38e59ef95d mysql "docker-entrypoint..." 2 seconds ago Up 2 seconds 0.0.0.0:53306->3306/tcp testmysql74d9a010c9b5 mysql "docker-entrypoint..." 24 minutes ago Up 6 minutes 3306/tcp mysqlb904506516a9 mysql_ubuntu_0.1 "/bin/bash" 10 hours ago Exited (0) 10 hours ago mysql_server9e78e89bdd4a ubuntu "/bin/bash" 11 hours ago Exited (0) 10 hours ago kickass_banach
第二個容器是不帶連接埠映射的(-p 53306:3306),外部存取不到
第一個容器就可以通過 192.168.99.100:53306 串連資料庫
https://hub.docker.com/_/mysql/http://blog.csdn.net/zistxym/article/details/43699029
windows10 docker 使用 mysql