1

When I do a docker-compose up for a docker-compose.yml containing only a db image

version: '3.3'
services:
    db_stations:
        image: mysql:5.7
        ...

I can see the following logs:

...
db_stations_1  | 2022-02-03T21:54:04.688034Z 0 [Note] Event Scheduler: Loaded 0 events
db_stations_1  | 2022-02-03T21:54:04.688369Z 0 [Note] mysqld: ready for connections.
...

So, when using the docker-maven-plugin to raise the docker when I run my service, I have the following configuration:

<build>
    <plugins>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.38.1</version>

            <configuration>
                <images>
                    <image>
                        <alias>stations_db</alias>
                        <name>mysql:5.7</name>
                        <run>
                            <wait>
                                <log>ready for connections</log>
                                <time>5000</time>
                            </wait>
                        </run>
                    </image>
                </images>
            </configuration>
            <executions>
                ...

It crahses with [ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.38.1:start (start) on project stations-service: I/O Error: [mysql:5.7] "stations_db": Container stopped with exit code 1 unexpectedly after 512 ms while waiting on log out 'ready for connections' -> [Help 1]

Not event waiting for 50000ms to crash. Curiously enough, if I change the log tag by the following:

<log>a</log> 

It works perfectly. So I have two different questions:

  1. Why does it crash even not waiting the expected time?
  2. How can I make it work with my desired string?

Many thanks in advance.

ldepablo
  • 424
  • 6
  • 19

1 Answers1

0

In my case, it works if I enclose the <log> pattern in a CDATA block, like this:

        <log><![CDATA[
port: 3306  MySQL Community Server - GPL
        ]]>
        </log>
        <time>30000</time>

I add a 30 sec timeout just in case. The default timeout is only 10 sec.

Hope it helps!