Update the image of one container

Set a new image only for the container named app

yq -i '(.spec.template.spec.containers[] | select(.name == "app") | .image) = "myapp:v2.0.0"' deployment.yaml

tool
yq15 commands
tags
yqci

More yq commands

  • yq '.metadata.name' manifests/*.yaml

    Print metadata.name from every YAML file in manifests/

  • yq '.spec.replicas' deployment.yaml

    Extract a value from a YAML file

  • yq -i '.spec.replicas = 3' deployment.yaml

    In-place update of a YAML field

  • yq -o=json deployment.yaml

    Print YAML as JSON, for example to pass it to jq

  • yq '. *= load("override.yaml")' base.yaml

    Deep-merge base.yaml with values from override.yaml

all 15 yq commands