yq -i '.services.api.ports = ["3000:3000"]' docker-compose.yml

Category: Web App Development

yq -i '.services.api.ports = ["3000:3000"]' docker-compose.yml

Edit a YAML value in place with yq

Rewrites docker-compose.yml setting the api service ports list, with -i saving changes back to the file. The expression uses jq-style assignment syntax. Back up the file first since in-place edits are irreversible.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.