cs202@cs202-devbox:~$ sudo docker run -d mysql
7698fdd7a2d05d38cf19c60cc9e35c1117fc551ae5e319144947154f4f353d23cs202@cs202-devbox:~$ sudo docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES257646e19a08 ubuntu "/bin/bash" 26 minutes ago Up 13 minutes desperate_ardinghellics202@cs202-devbox:~$ sudo docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES7698fdd7a2d0 mysql "/entrypoint.sh mysql" 18 seconds ago Exited (1) 17 seconds ago desperate_swanson151a8113ba67 mysql "/entrypoint.sh mysql" 5 minutes ago Exited (1) 5 minutes ago hopeful_williams257646e19a08 ubuntu "/bin/bash" 27 minutes ago Up 13 minutes desperate_ardinghelli发现并没有成功启动,查看日志:cs202@cs202-devbox:~$ sudo docker logs desperate_swansonerror: 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于是设置MYSQL_ROOT_PASSWORD:sudo docker run -e MYSQL_ROOT_PASSWORD=wwwwww --name mysql -d mysql总算启动成功了:^Ccs202@cs202-devbox:~sudo docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESb50461bd8135 mysql "/entrypoint.sh mysql" 4 minutes ago Up 4 minutes 3306/tcp mysql257646e19a08 ubuntu "/bin/bash" 37 minutes ago Up 23 minutes desperate_ardinghellics202@cs202-devbox:~$ 后台打印出大片日志:cs202@cs202-devbox:~$ sudo docker logs -f mysql2016-03-12T02:50:26.302319Z 0 [Note] InnoDB: Highest supported file format is Barracuda.2016-03-12T02:50:26.375013Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables2016-03-12T02:50:26.375515Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...2016-03-12T02:50:26.444508Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.2016-03-12T02:50:26.446893Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.2016-03-12T02:50:26.447017Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.2016-03-12T02:50:26.451067Z 0 [Note] InnoDB: Waiting for purge to start2016-03-12T02:50:26.504451Z 0 [Note] InnoDB: 5.7.11 started; log sequence number 119915122016-03-12T02:50:26.505028Z 0 [Note] Plugin 'FEDERATED' is disabled.2016-03-12T02:50:26.508912Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key2016-03-12T02:50:26.509170Z 0 [Note] Server hostname (bind-address): '*'; port: 33062016-03-12T02:50:26.509310Z 0 [Note] IPv6 is available.2016-03-12T02:50:26.509366Z 0 [Note] - '::' resolves to '::';2016-03-12T02:50:26.509419Z 0 [Note] Server socket created on IP: '::'.2016-03-12T02:50:26.509154Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool2016-03-12T02:50:26.519321Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.2016-03-12T02:50:26.519569Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.2016-03-12T02:50:26.544083Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160312 2:50:262016-03-12T02:50:26.548848Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.2016-03-12T02:50:26.565564Z 0 [Note] Event Scheduler: Loaded 0 events2016-03-12T02:50:26.566266Z 0 [Note] mysqld: ready for connections.Version: '5.7.11' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)如果需要指定端口的话,加-p选项:docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql/mysql-server:latest