ansible-container没有挂载我的音量

时间:2017-12-25 12:52:44

标签: docker ansible-container

我有两个简单的服务:adminer和mysql。

container.yml:

--1. Create a temporary table that we can take as base table (#TMP)
Select *
INTO #TMP
From
(
Select 44 as TLRef, 1 as deb, 0 as cred, '1396/09/12' as Date, 111 as TLCode, 16 as DocTLHeaderRef, 2 as Num Union All
Select 44 as TLRef, 1 as deb, 0 as cred, '1396/09/21' as Date, 111 as TLCode, 18 as DocTLHeaderRef, 4 as Num Union All
Select 28 as TLRef, 13 as deb, 0 as cred, '1396/09/11' as Date, 982 as TLCode, 15 as DocTLHeaderRef, 1 as Num Union All
Select 28 as TLRef, 10 as deb, 0 as cred, '1396/09/19' as Date, 982 as TLCode, 17 as DocTLHeaderRef, 3 as Num Union All
Select 44 as TLRef, 0 as deb, 10 as cred, '1396/09/19' as Date, 111 as TLCode, 17 as DocTLHeaderRef, 3 as Num Union All
Select 44 as TLRef, 0 as deb, 1 as cred, '1396/09/21' as Date, 111 as TLCode, 18 as DocTLHeaderRef, 4 as Num Union All
Select 44 as TLRef, 0 as deb, 9 as cred, '1396/09/11' as Date, 111 as TLCode, 15 as DocTLHeaderRef, 1 as Num Union All
Select 44 as TLRef, 0 as deb, 1 as cred, '1396/09/12' as Date, 111 as TLCode, 16 as DocTLHeaderRef, 2 as Num
) X

--2. Group table by "Date" and select sum of "deb", "cred" columns and insert result in another temporary table (#TMP2)
Select null as TLRef, SUM(deb) as deb, SUM(cred) as cred, Date, null as TLCode, null as DocTLHeaderRef, null as Num 
INTO #TMP2
From #TMP 
GROUP BY Date

--3. Union both tables to resulting table gets both detail and grouped data.
Select *
From
(
    Select *, 0 as IsDetail From #TMP
    Union All
    Select *, 1 as IsDetail From #TMP2
) X
Order By Date,IsDetail

--4. Drop both temporary table
DROP TABLE #TMP
DROP TABLE #TMP2

但是在构建和运行之后,创建的容器上没有/var/dump.sql文件,并且当我使用--debug模式运行它时没有错误。此外,有一个新的卷我没有在我的container.yml文件中定义,但不知何故它已创建:

version: "2"
settings:

  conductor_base: debian:stretch
  project_name: Ansible-container

defaults:
  DB_HOST: mysql
  DB_USER: test
  DB_PASS: *********
  DB_NAME: test

services:

  adminer:
    from: adminer
    links:
      - mysql
    ports:
      - 8080:8080

  mysql:
    from: mysql:5.7
    volumes:
      - /home/argonavt/ansible-container/dump.sql:/var/dump.sql
    environment:
      MYSQL_DATABASE: "{{ DB_NAME }}"
      MYSQL_USER: "{{ DB_USER }}"
      MYSQL_PASSWORD: "{{ DB_PASS }}"
      MYSQL_ROOT_PASSWORD: "{{ DB_USER }}{{ DB_PASS }}"

registries: {}

它是如何工作的?怎么知道mysql数据应该在卷上?为什么不看我自己的卷?

如果我在docker-compose上运行相同的服务,一切都很好。

版本:

  • Ansible Container,版本0.9.2。
  • Docker版本17.09.1-ce。

我将不胜感激任何帮助。感谢。

1 个答案:

答案 0 :(得分:0)

挂载目录而不是文件,因此请跳过x.sql