docker运行的完全等效“-c”

使用自定义configuration运行docker postgres容器,您可以使用如下命令:

“docker container run -d postgres -c max_connections = 6 -c log_lock_waits = on”

我的任务是:

name: Start postgis become: true docker_container: name: postgis image: "{{ ecr_url }}" network_mode: bridge exposed_ports: 5432 published_ports: 5432:5432 state: started volumes: - /mnt/datadir/pgdata:/var/lib/postgresql/data 

这将确实运行的容器,但那么我的问题是:

Docker运行命令中“-c”标志的等价物是什么?


感谢larsks的答案,你可以发送多个命令一个在另一个之下

 published_ports: 5432:5432 state: started command: -c shared_buffers = 24000MB -c work_mem=16MB -c maintenance_work_mem = 128MB -c etcetera 

请记住docker run的语法是:

 docker run [...docker options...] image [...command and args...] 

考虑到这一点,看看你的命令行:

 docker container run -d postgres -c max_connections=6 -c log_lock_waits=on 

这些-c参数图像名称之后,所以它们不是 docker run标志。 它们是传递给容器的命令的一部分,在这种情况下,它们最终成为postgres命令的参数。

所以在Ansible中,你只需要:

 docker_container: name: postgis image: "{{ ecr_url }}" command: "-c max_connections=6 -c log_lock_waits=on"