How to pass arguments to a container's entrypoint in Docker Compose?

I am using the Postgres container in a Docker Compose setup. I need to configure the container on launch by passing an argument to the entrypoint script. If I were doing this on the command line, it would look like this:

$ docker run --rm -p 5432:5432 postgres:11.1 -c fsync=off

But I’m using Compose. When I add command: fsync=off to my db service the compose yaml file, the result is:

/usr/local/bin/docker-entrypoint.sh: line 322: exec: fsync=off: not found

So how do I pass this configuration argument to the entrypoint script? The docs on the Postgres Docker container say:

The entrypoint script is made so that any options passed to the docker command will be passed along to the postgres server daemon. From the docs we see that any option available in a .conf file can be set via -c.

But I don’t see anything about Compose.

You forgot to add -c to the command. It is required by postgres not the Docker command.

command: -c fsync=off

or

command:
  - "-c"
  - "fsync=off"
2 Likes

Yep, that was it. Thank you for the super quick response!

1 Like