Created
November 25, 2015 17:36
-
-
Save chuyihuang/dec34b2fdf9e1f39abb8 to your computer and use it in GitHub Desktop.
docker建立mysql的data only container,存放資料庫避免container移除時資料遺失
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#使用busybox做為container的image | |
#執行以下: | |
docker run -v /var/lib/mysql --name app_data busybox | |
# -v掛載/var/li/mysql路徑的資料,並在busybox上建立一個名為app_data的container | |
# 透過docker ps-a 觀察建立結果,結果是exit,這是正常結果,因為只是做掛載實體檔案的動作 | |
#串聯管理mysql的container: | |
docker run -P --volumes-from app_data --name mysql -e MYSQL_ROOT_PASSWORD=aabbcc -d -t mysql:latest | |
#-P 表示開放全部的連接阜給其他container,並且透過--volumes-from掛載路徑資料的container,然後帶入環境參數,aabbcc只是舉例。 | |
# 完成後用docker ps -a檢查是否正確執行 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment