Search code examples
dockervirtual-machineoverlaydocker-swarmdocker-machine

Detected task failure: docker service create --name db --network backend --mount type=volume,source=db-data,target=/var/lib/postgresql/data postgres


I'm running Docker with Bash on windows 10.

Inside my VM node1, when I run this command

docker service create --name db --network backend --mount type=volume,source=db-data,target=/var/lib/postgresql/data postgres:9.4

I get:

overall progress: 0 out of 1 tasks
1/1: ready
verify: Detected task failure
♥Operation continuing in background.
Use `docker service ps tm3hgzidbr2smnpc7f2tz1w67` to check progress.

Why did the task fail?


Solution

  • SOLVED

    I was missing an argument that is mandatory for postgres authentication: -e POSTGRES_HOST_AUTH_METHOD=trust.

    From Docker HUB documentation on Postgres:

    -e POSTGRES_HOST_AUTH_METHOD=trust
    

    Set the auth-method for host connections for all databases, all users, and all addresses. The following will be added to the pg_hba.conf if this option is passed: host all all all $POSTGRES_HOST_AUTH_METHOD.

    so I removed my db service

    docker service rm db
    

    and replaced it with

    docker service create --network backend --mount type=volume,source=db-data,target=/var/lib/postgresql/data --name db -e POSTGRES_HOST_AUTH_METHOD=trust postgres:9.4