2017-07-27 57 views
1

我試圖用docker-maven-plugin配置MongoDB映像。docker-maven-plugin與MongoDB映像在啓動時掛起

這是我的配置:

<plugin> 
    <groupId>io.fabric8</groupId> 
    <artifactId>docker-maven-plugin</artifactId> 
    <version>0.21.0</version> 

    <configuration> 
     <showLogs>true</showLogs> 

     <images> 
      <image> 
       <name>mongo:3.0.15</name> 
       <alias>mongo</alias> 
       <run> 
        <ports> 
         <port>27017:27017</port> 
        </ports> 
        <wait> 
         <log>waiting for connections on port</log> 
         <time>60000</time> 
        </wait> 
       </run> 
      </image> 
     </images> 
    </configuration> 

    <executions> 
     <execution> 
      <id>prepare-containers</id> 
      <phase>pre-integration-test</phase> 
      <goals> 
       <goal>start</goal> 
      </goals> 
     </execution> 
     <execution> 
      <id>remove-containers</id> 
      <phase>post-integration-test</phase> 
      <goals> 
       <goal>stop</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

當我調用

MVN搬運工:啓動-Dfile.encoding = UTF-8

調用具有以下輸出掛起:

D:\Projects\decisionwanted\domain>mvn docker:start -Dfile.encoding=UTF-8 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building domain 0.0.1 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- docker-maven-plugin:0.21.0:start (default-cli) @ domain --- 
[INFO] DOCKER> [mongo:3.0.15] "mongo": Start container af3368374f17 
mongo> 2017-07-27T07:48:55.621+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=af3368374f17 
mongo> 2017-07-27T07:48:55.621+0000 I CONTROL [initandlisten] db version v3.0.15 
mongo> 2017-07-27T07:48:55.621+0000 I CONTROL [initandlisten] git version: b8ff507269c382bc100fc52f75f48d54cd42ec3b 
mongo> 2017-07-27T07:48:55.621+0000 I CONTROL [initandlisten] build info: Linux ip-10-166-66-3 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 BOOST_LIB_VERSION=1_49 
mongo> 2017-07-27T07:48:55.621+0000 I CONTROL [initandlisten] allocator: tcmalloc 
mongo> 2017-07-27T07:48:55.621+0000 I CONTROL [initandlisten] options: {} 
mongo> 2017-07-27T07:48:55.637+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal 
mongo> 2017-07-27T07:48:55.638+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed 
mongo> 2017-07-27T07:48:55.783+0000 I JOURNAL [initandlisten] preallocateIsFaster=true 2.54 
mongo> 2017-07-27T07:48:55.824+0000 I JOURNAL [durability] Durability thread started 
mongo> 2017-07-27T07:48:55.824+0000 I JOURNAL [journal writer] Journal writer thread started 
mongo> 2017-07-27T07:48:55.829+0000 I INDEX [initandlisten] allocating new ns file /data/db/local.ns, filling with zeroes... 
mongo> 2017-07-27T07:48:55.874+0000 I STORAGE [FileAllocator] allocating new datafile /data/db/local.0, filling with zeroes... 
mongo> 2017-07-27T07:48:55.874+0000 I STORAGE [FileAllocator] creating directory /data/db/_tmp 
mongo> 2017-07-27T07:48:55.875+0000 I STORAGE [FileAllocator] done allocating datafile /data/db/local.0, size: 64MB, took 0 secs 
mongo> 2017-07-27T07:48:55.878+0000 I NETWORK [initandlisten] waiting for connections on port 27017 

如何使用docker-maven-plugin正確配置MongoDB映像?

回答

0

以下配置工作正常:

   <image> 
        <name>mongo:3.4.6</name> 
        <alias>mongo</alias> 
        <run> 
         <ports> 
          <port>${mongodb.port}:27017</port> 
         </ports> 
         <env> 
         <MONGO_INITDB_ROOT_USERNAME>${mongodb.username}</MONGO_INITDB_ROOT_USERNAME> 
         <MONGO_INITDB_ROOT_PASSWORD>${mongodb.password}</MONGO_INITDB_ROOT_PASSWORD> 

         </env> 
         <wait> 
          <log>waiting for connections on port</log> 
          <time>60000</time> 
         </wait> 
        </run> 
       </image>