When I use docker compose config to create a single file, my db service ports also rendered but published one is a string variable therefore I get this:
services.db.ports.0.published must be a integer
Docker compose with the ports:
version: '3.6'
services:
db:
ports:
- 4545:5432
Rendered result:
db:
deploy:
replicas: 1
update_config:
parallelism: 1
order: stop-first
placement:
constraints:
- node.labels.prod == true
environment:
POSTGRES_DB: mydb
POSTGRES_PASSWORD_FILE: /run/secrets/postgres-password
POSTGRES_USER: postgres
image: postgres:12
networks:
default: null
ports:
- mode: ingress
target: 5432
published: "4545" ------------------------> Making this an integer fix it
protocol: tcp
When I remove the quotation marks it fixes this but how can I run the config command to not get this error?
is this the best way?
sed "s/published:.*/published: 4545/g"