docker探索-windows10 docker 使用 mysql(二)

转自:http://blog.csdn.net/daocaoren92wq/article/details/68484049
$ docker pull mysql
docker@default:~$ 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 docker@default:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql_ubuntu_0. latest c3fb44aa3b0f hours ago MB
mysql latest 5faba1a71ec4 days ago MB
ubuntu latest 0ef2e08ed3fa weeks ago 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 端口号映射

docker@default:~$ docker run -p : --name testmysql -e MYSQL_ROOT_PASSWORD= -d mysql
6a38e59ef95d1a3f63a12d9c6c2ae20cf782001f25641f5159812e2a707f3f1d docker@default:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a38e59ef95d mysql "docker-entrypoint..." seconds ago Up seconds 0.0.0.0:->/tcp testmysql
74d9a010c9b5 mysql "docker-entrypoint..." minutes ago Up minutes /tcp mysql
b904506516a9 mysql_ubuntu_0. "/bin/bash" hours ago Exited () hours ago mysql_server
9e78e89bdd4a ubuntu "/bin/bash" hours ago Exited () 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
上一篇:Android Studio 直播弹幕


下一篇:如何去掉Json字符串中反斜杠