user8258386
user8258386

Reputation:

Docker Swarm postgresql Cluster --mount key=value pair error

Im trying to set up a Postgresql Cluster with 4 machines (running ubuntu), 1 Swarm manager and 3 worker - 1 worker should running the master database (read/write) und the other worker should be a slave database (read-only). Just like in this example: http://info.crunchydata.com/blog/easy-postgresql-cluster-recipe-using-docker-1.12

I made my costum postgres image exposing the port etc...

But im stuck with generating the swarm with the needed env variables.

docker service create \
> --name pu06suzdrm63peraqcuzi697z \
> --mount type=volume, src=pu06suzdrm63peraqcuzi697z-
volume,dst=/pgdata,volume-driver=local \
> --network overlay \
> --constraint 'node.labels.type == master' \
> --env PGHOST=/tmp \
> --env PG_USER=testuser \
> --env PG_MODE=master \
> --env PG_MASTER_USER=master \
> --env PG_ROOT_PASSWORD=password \
> --env PG_PASSWORD=password \
> --env PG_DATABASE=userdb \
> --env PG_MASTER_PORT=5432 \
> --env PG_MASTER_PASSWORD=password \
> xxxx/my_image

i get this error back:

invalid argument "type=volume," for "--mount" flag: invalid field '' must be a key=value pair

?

Upvotes: 0

Views: 1500

Answers (1)

yamenk
yamenk

Reputation: 51758

The problem is with the space between the type and src option for the mount. The src is being interpreted as a option for the create option and not the mount option. This can be verified from the error message where volume, with the comma is being parsed as a value for type.

docker service create \
--name pu06suzdrm63peraqcuzi697z \
--mount type=volume,src=pu06suzdrm63peraqcuzi697z-volume,dst=/pgdata,volume-driver=local \
--network overlay \
--constraint 'node.labels.type == master' \
--env PGHOST=/tmp \
--env PG_USER=testuser \
--env PG_MODE=master \
--env PG_MASTER_USER=master \
--env PG_ROOT_PASSWORD=password \
--env PG_PASSWORD=password \
--env PG_DATABASE=userdb \
--env PG_MASTER_PORT=5432 \
--env PG_MASTER_PASSWORD=password \ 
xxxx/my_image

Upvotes: 2

Related Questions