0

I am in some desperate help. I am atempting to translate this docker run command:

docker run -d -p 5434:5432 --name postgres-2 livingdocs/postgres:14.4 standby -d "host=host.docker.internal port=5433 user=postgres target_session_attrs=read-write"

which works flawlessly, but when I attempt to convert it to docker_compose.yml:

  postgres-2:
    image: livingdocs/postgres:14.4
    container_name: postgres-SLAVE
    ports:
      - "5434:5432"
    volumes:
      - postgres2:/tmp/data
    entrypoint: "/scripts/entrypoint standby"
    command:
      - host=host.docker.internal
      - port=5433
      - user=postgres
      - target_session_attrs=read-write"

It throws:

pg_basebackup: error: too many command-line arguments (first is "host=host.docker.internal")

Try "pg_basebackup --help" for more information.

After I save the yml file and execute: docker-compose up -d --remove-orphans

I've tried the online conversion tools and about 300 variations, but I cannot get to function the same as docker run.

1
  • I might be wrong, but it looks like in your original docker command the whole string is passed as a single argument.
    – tkausl
    Jun 28, 2022 at 8:58

2 Answers 2

0

Why in your docker-compose.yml are you setting entrypoint, when your docker run command does not have a --entrypoint option? You've also removed the -d option from the invocation, and you're passing the remaining options as individual arguments rather than the single string you're using in the docker run invocation.

The equivalent to your docker run command line would be:

  postgres-2:
    image: livingdocs/postgres:14.4
    container_name: postgres-SLAVE
    ports:
      - "5434:5432"
    command:
      - standby
      - -d
      - "host=host.docker.internal port=5433 user=postgres target_session_attrs=read-write"

I've removed the volumes stanza, since you're not using any volumes on the docker run command line.

0

I got it working with:

  postgres-2:
    image: livingdocs/postgres:14.4
    container_name: postgres-SLAVE
    ports:
      - "5434:5432"
    volumes:
      - postgres2:/tmp/data
    entrypoint:
      - standby
    command: "--host host.docker.internal --port 5433 --user postgres"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.