1. 程式人生 > >windows10 docker 使用 mysql

windows10 docker 使用 mysql

images ace avr eat load tps log style blog

轉自:http://blog.csdn.net/daocaoren92wq/article/details/68484049
$ docker pull mysql [email protected]:
~$ docker pull mysql Using default tag: latest latest: Pulling from library/mysql 6d827a3ef358: 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:b39e58483853ecd03160f9bfdc8d3ecb0be9071fdbbe5484d6a115677b62c84e Status: Downloaded newer image
for mysql:latest [email protected]:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql_ubuntu_0.1 latest c3fb44aa3b0f 10 hours ago 130 MB mysql latest 5faba1a71ec4 8 days ago 407
MB ubuntu 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 mysql 6a38e59ef95d1a3f63a12d9c6c2ae20cf782001f25641f5159812e2a707f3f1d [email protected]:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6a38e59ef95d mysql "docker-entrypoint..." 2 seconds ago Up 2 seconds 0.0.0.0:53306->3306/tcp testmysql 74d9a010c9b5 mysql "docker-entrypoint..." 24 minutes ago Up 6 minutes 3306/tcp mysql b904506516a9 mysql_ubuntu_0.1 "/bin/bash" 10 hours ago Exited (0) 10 hours ago mysql_server 9e78e89bdd4a 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