標籤:
1、安裝docker,網上一堆,這裡不細說。
2、進入linux後,使用docker命令下載mysql,命令如:
docker pull mysql:5.7
運行該命令後,則會顯示以下日誌:
5.7: Pulling from mysql
4c8cbfd2973e: Pull complete
60c52dbe9d91: Pull complete
c2b0136be90f: Pull complete
273cd71eacf0: Pull complete
543ff72402d8: Pull complete
f928e22e58b0: Pull complete
2d1023ecaed4: Pull complete
059dbbef4dd8: Pull complete
ac0ee0367a32: Pull complete
a9057a689e83: Pull complete
5191ddfc3b01: Pull complete
6e2ce31eb835: Pull complete
099dc92e9b15: Pull complete
7b4030a6b20b: Pull complete
fdb9c2185fc2: Already exists
mysql:5.7: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:d00f3f3cd30d0e8ad9bdf8ba61729ee1a4b6fe84a0fbb95f07dc2668a4cb5d08
Status: Downloaded newer image for mysql:5.7
下載需要一段時間,下載完畢後,啟動docker容器。
3、先查看本機都有哪些鏡像,命令如下:docker images
然後會列印出以下日誌:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
mysql 5.7 fdb9c2185fc2 9 days ago 321.9 MB
csphere/csphere 0.11.2 6d983828b938 8 weeks ago 112 MB
4、然後啟動我們的mysql的docker容器,命令如下:
docker run --name db001 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mytest -d mysql:5.7
注意,這裡的容器名字叫:db001,mysql的root使用者密碼是:mytest,映射宿主機子的連接埠3306到容器的連接埠3306,倉庫名mysql和標籤(tag)唯一確定了要指定的鏡像,其實如果這裡只有一個mysql也有必要要tag,執行該命令返回的結果是:
a40c6e58afbda0199111a2a2ef0af7e8dd9be057a610ca5f4f30aa782a5d9155
5、查看已經啟動並執行的所有容器,命令如:docker ps
返回的結果是:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a40c6e58afbd mysql:5.7 "/entrypoint.sh mysq 12 seconds ago Up 12 seconds 0.0.0.0:3306->3306/tcp db001
512013f5bd3a csphere/csphere:0.11.2 "/bin/csphere-init - 10 days ago Up 10 days csphere-agent
631a4f91b2fb csphere/csphere:0.11.2 "/bin/csphere-init - 10 days ago Up 10 days 8086/tcp, 27017/tcp, 0.0.0.0:1016->80/tcp csphere-controller
使用mysql的工具,比如navicat串連成功。
這裡我們沒有製作自己的鏡像,直接使用了網上已有的,開始是從docker pull dl.dockerpool.com:5000/mysql:5.7路徑上pull myql鏡像,結果沒有成功,所以直接使用了上邊說的docker pull mysql:5.7,沒有什麼技術含量,給入門的同學用吧。
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
linux的docker上如何安裝mysql