2016-12-30 62 views
2

我有它的數據庫中泊塢窗的Web應用程序,我已經設置了:數據庫中泊塢窗應用

-v /home/stephane/dev/php/learnintouch/docker/mysql/data:/usr/bin/mysql/install/data 

它工作正常,但我不知道這是否是去的推薦方式。

因爲我看我們也可以通過在主機上給人一種名稱,而不是一個絕對路徑創建一個名爲卷:

-v learnintouch-data:/usr/bin/mysql/install/data 

但後來,我怎麼能卷名learnintouch數據與主機關聯位置在/home/stephane/dev/php/learnintouch/docker/mysql/data

這是我目前的docker-compose.yml文件:

learnintouch.com-startup: 
    image: stephaneeybert/learnintouch.com-startup 
    container_name: learnintouch.com-startup 
    ports: 
    - "80:80" 
    links: 
    - mysql 
    - redis 
    - nodejs-learnintouch 
nodejs-learnintouch: 
    image: stephaneeybert/nodejs-learnintouch 
    container_name: nodejs-learnintouch 
    ports: 
    - "9001:9001" 
    links: 
    - redis 
mysql: 
    image: stephaneeybert/mysql:5.6.30 
    container_name: mysql 
    ports: 
    - "3306:3306" 
    environment: 
    - MYSQL_ROOT_PASSWORD=root 
    volumes: 
    - "/home/stephane/dev/php/learnintouch/docker/mysql/data:/usr/bin/mysql/install/data" 
redis: 
    image: stephaneeybert/redis:3.0.7 
    container_name: redis 
    ports: 
    - "6379:6379" 

回答

0

使用一個名爲體積(或更具體地說使用泊塢引擎容積API創建的卷)與定義的主機的路徑並沒有太大的優勢你使用的方法。從技術上講,創建一個新的容器是「更容易」的,但僅僅是因爲你不再需要記住路徑。您還可以使用卷API獨立於應用程序容器來「管理」卷,但使用docker容器API同樣很容易。

如果您堅持要使用絕對主機路徑創建命名卷,則需要使用卷驅動程序。我會建議本地堅持。這很簡單,安裝和運行良好。

https://github.com/CWSpear/local-persist