Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start Postgres using PropertyConfigHandler #451

Closed
Ironlink opened this issue May 18, 2016 · 7 comments
Closed

Unable to start Postgres using PropertyConfigHandler #451

Ironlink opened this issue May 18, 2016 · 7 comments

Comments

@Ironlink
Copy link

When I try to launch the official Postgres image using properties configuration, it fails with the following error:

postgres> "root" execution of the PostgreSQL server is not permitted.
postgres> The server must be started under an unprivileged user ID to prevent
postgres> possible system security compromise.  See the documentation for
postgres> more information on how to properly start the server.
  • I have tried versions 9.5.2 and 8 of the image, both with the same error.
  • I have tried running the shootout-docker-maven project. This works as intended.
  • I have tried running the 9.5.2 image from command line. This works as intended.

Using debug logging, I have extracted this as the call made to Docker when the error occurs:

{
    "Cmd": [],
    "Entrypoint": [],
    "Env": ["POSTGRES_PASSWORD=superuser-password", "POSTGRES_USER=superuser"],
    "ExposedPorts": {
        "5432/tcp": {}
    },
    "HostConfig": {
        "PortBindings": {
            "5432/tcp": [{
                "HostPort": ""
            }]
        },
        "VolumesFrom": []
    },
    "Image": "postgres:9.5.2",
    "Labels": {
        "dmp.coordinates": "(removed)"
    }
}

One thing that stands out is that there are empty arrays being sent for Cmd, Entrypoint and VolumesFrom. These are not present when running shootout-docker-maven.
For my project, I have these properties in (project-root)/docker-setup/postgres.properties:

postgres.docker.name=postgres:9.5.2
postgres.docker.log.prefix=postgres
postgres.docker.ports.1=${itest.postgres.host}:${itest.postgres.port}:5432
postgres.docker.env.POSTGRES_USER=superuser
postgres.docker.env.POSTGRES_PASSWORD=superuser-password
postgres.docker.wait.time=10000
postgres.docker.wait.log=PostgreSQL init process complete

My maven config looks like this:

        <profile>
            <id>docker-testing</id>
            <activation>
                <property>
                    <name>docker-testing</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>properties-maven-plugin</artifactId>
                        <version>1.0.0</version>
                        <executions>
                            <execution>
                                <phase>initialize</phase>
                                <goals><goal>read-project-properties</goal></goals>
                            </execution>
                        </executions>
                        <configuration>
                            <files>
                                <file>${session.executionRootDirectory}/docker-setup/postgres.properties</file>
                            </files>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>0.15.1</version>
                        <executions>
                            <execution>
                                <id>start-docker</id>
                                <phase>pre-integration-test</phase>
                                <goals><goal>start</goal></goals>
                            </execution>
                            <execution>
                                <id>stop-docker</id>
                                <phase>post-integration-test</phase>
                                <goals><goal>stop</goal></goals>
                            </execution>
                        </executions>
                        <configuration>
                            <removeVolumes>true</removeVolumes>
                            <images>
                                <image>
                                    <external>
                                        <type>props</type>
                                        <prefix>postgres.docker</prefix>
                                    </external>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
@rhuss
Copy link
Collaborator

rhuss commented May 19, 2016

Thanks, will try to reproduce it.

@rhuss
Copy link
Collaborator

rhuss commented May 19, 2016

I had a different issue with your setup (with tcpWait stuff added accidentally), which I just fixed and it works now for me.

I just pushed a 0.15.2-SNAPSHOT to maven central, could you try this ?

@Ironlink
Copy link
Author

Yes, with this snapshot Postgres starts up successfully. This is great!

However, the :ro suffix for read-only volumes appears to be broken in this snapshot.

@rhuss
Copy link
Collaborator

rhuss commented May 19, 2016

cool, will check that.

btw, do you think it would be a good idea to allow the inclusion of a property file directly in the <external> configuration section ? This would save you the usage of the maven-properties-plugin.

@Ironlink
Copy link
Author

Yes, that would certainly be nice to have, but you would have to include some implementation of substituting variables such as ${user.dir} and ${project.basedir}. I don't know if this functionality is available from some library or if you would have to copy and maintain the code from some open source project.

@rhuss
Copy link
Collaborator

rhuss commented May 19, 2016

Shouldnt be that hard, Maven has an internal service who does property resolution. I will give it a shot.

@rhuss
Copy link
Collaborator

rhuss commented May 20, 2016

Fixed in 0.15.2

@rhuss rhuss closed this as completed May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants