Two port lists
Appended, so the override adds a port and cannot take the first one away
services:
web:
image: myapp
ports:
- "8080:80"
---
services:
web:
ports:
- "9090:80" See what a stack of -f files produces. Put the base above a line of three dashes and the override below, in the order you pass them.
Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.
The answer appears here
Paste on the left and press Merge. Nothing leaves this tab.
Nothing else to flag.
No formatting problems, and nothing the rules object to. Worth remembering what that covers: this reads the file you pasted, not the account or cluster it will be applied to.
No finding matches that filter.
Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.
Appended, so the override adds a port and cannot take the first one away
services:
web:
image: myapp
ports:
- "8080:80"
---
services:
web:
ports:
- "9090:80"Replaced wholesale, which is the opposite of how ports behaves
services:
web:
image: myapp
command: ["serve", "--port", "80"]
---
services:
web:
command: ["debug"]What appending produces, and the error looks like something else holding the port
services:
web:
ports:
- "8080:80"
---
services:
web:
ports:
- "8080:3000"These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.
ports is appended, so the result publishes both. There is no syntax for removing an entry.
Instead:Take the port out of the base file and add it in the overrides that want it.
command, entrypoint and healthcheck are replaced entirely, even though they are written as lists.
Instead:Write the whole command in the override. Nothing from the base carries over.
Relative paths resolve against the first file's directory, so a build context written relative to the override points somewhere that does not exist.
Instead:Keep them beside the base file, use absolute paths, or pass --project-directory.
ports, volumes and cap_add are concatenated. command, entrypoint and healthcheck are replaced. Both are lists and there is nothing in the syntax to tell them apart.
An override written to stop publishing a port publishes both. A base with a development bind mount cannot have it taken away in a production override. There is no removal syntax at all, so the only fix is restructuring so the base does not have the entry in the first place.
Anything environment-specific belongs in the overrides rather than as a default in the base that one of them then tries to undo. That inverts the instinct to put sensible defaults at the bottom.
Despite being lists. They are single values that happen to be written as sequences, so the override's version stands alone and nothing from the base survives. That is the opposite of ports, in the same merge.
So an override can change one variable without restating the rest, and both the list form and the map form work. This is the behaviour people expect from all of it, which is part of why the appended keys surprise.
The project directory comes from the first -f. A build context or a bind mount written relative to an override kept in a subdirectory resolves somewhere else entirely, and the error is a missing path that plainly exists.