docker 启动mysql以及问题 -e MYSQL_ROOT_PASSWORD=my-secret-pw

docker pull mysql

docker run -d -P mysql

docker ps -a 发现没有启动

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES
10267bae0be0        mysql               "docker-entrypoint.sh"   2 minutes ago       Exited (1) 6 seconds ago                       amazing_lalande


查看日志

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES
10267bae0be0        mysql               "docker-entrypoint.sh"   2 minutes ago       Exited (1) 6 seconds ago                       amazing_lalande

docker logs 10


error: database is uninitialized and password option is not specified
  You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

启动加入-e MYSQL_ROOT_PASSWORD=my-secret-pw 设置root用户密码

docker run -d -P -e MYSQL_ROOT_PASSWORD=root mysql


重命名容器名

sudo docker rename modest_goldberg mysql


sudo docker run --name mysql_client --link mysql:db -d mysql


然后连接至mysql



docker run 命令参数

-d 后台运行

-p 暴露端口

-e 设置环境变量,与在dockerfile env设置相同效果

--name 设置namne


https://hub.docker.com/_/mysql/

http://blog.csdn.net/wongson/article/details/49077353


你可能感兴趣的:(docker)