Arguments in docker_compose.yml throwing error, but not with docker run



  • 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.


  • QA Engineer

    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.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2