2016-12-30 59 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