diff --git a/chartpress.py b/chartpress.py
index 95fc5ad..23a280b 100755
--- a/chartpress.py
+++ b/chartpress.py
@@ -13,6 +13,7 @@ import pipes
 import re
 import shutil
 import subprocess
+import sys
 from tempfile import TemporaryDirectory
 
 import docker
@@ -33,14 +34,26 @@ yaml.preserve_quotes = True ## avoid mangling of quotes
 yaml.indent(mapping=2, offset=2, sequence=4)
 
 
+def log(message):
+    """Print messages to stderr
+
+    to avoid conflicts with piped output, e.g. `--list-images`
+    """
+    print(message, file=sys.stderr)
+
+
 def run_cmd(call, cmd, *, echo=True, **kwargs):
     """Run a command and echo it first"""
     if echo:
-        print('$> ' + ' '.join(map(pipes.quote, cmd)))
+        log("$> " + " ".join(map(pipes.quote, cmd)))
     return call(cmd, **kwargs)
 
 
-check_call = partial(run_cmd, subprocess.check_call)
+def check_call(cmd, **kwargs):
+    kwargs.setdefault("stdout", sys.stderr.fileno())
+    return run_cmd(subprocess.check_call, cmd, **kwargs)
+
+
 check_output = partial(run_cmd, subprocess.check_output)
 
 
@@ -381,7 +394,7 @@ def build_images(prefix, images, tag=None, push=False, force_push=False, chart_v
             )
             build_image(image_spec, context_path, dockerfile_path=dockerfile_path, build_args=build_args)
         else:
-            print(f"Skipping build for {image_spec}, it already exists")
+            log(f"Skipping build for {image_spec}, it already exists")
 
         if push or force_push:
             if force_push or image_needs_pushing(image_spec):
@@ -389,7 +402,7 @@ def build_images(prefix, images, tag=None, push=False, force_push=False, chart_v
                     'docker', 'push', image_spec
                 ])
             else:
-                print(f"Skipping push for {image_spec}, already on registry")
+                log(f"Skipping push for {image_spec}, already on registry")
     return value_modifications
 
 
@@ -419,7 +432,7 @@ def build_values(name, values_mods):
                 for repo_key in keys:
                     before = mod_obj.get(repo_key, None)
                     if before != value['repository']:
-                        print(f"Updating {values_file}: {key}.{repo_key}: {value}")
+                        log(f"Updating {values_file}: {key}.{repo_key}: {value}")
                     mod_obj[repo_key] = value['repository']
             else:
                 possible_keys = ' or '.join(IMAGE_REPOSITORY_KEYS)
@@ -429,7 +442,7 @@ def build_values(name, values_mods):
 
             before = mod_obj.get('tag', None)
             if before != value['tag']:
-                print(f"Updating {values_file}: {key}.tag: {value}")
+                log(f"Updating {values_file}: {key}.tag: {value}")
             mod_obj['tag'] = value['tag']
         elif isinstance(mod_obj, str):
             # scalar image string, not dict with separate repository, tag keys
@@ -439,7 +452,7 @@ def build_values(name, values_mods):
             except (KeyError, IndexError):
                 before = None
             if before != image:
-                print(f"Updating {values_file}: {key}: {image}")
+                log(f"Updating {values_file}: {key}: {image}")
             parent[last_part] = image
         else:
             raise TypeError(
@@ -500,7 +513,7 @@ def build_chart(name, version=None, paths=None, long=False):
             version = _get_identifier(latest_tag_in_branch, n_commits, chart_commit, long)
 
     if chart['version'] != version:
-        print(f"Updating {chart_file}: version: {version}")
+        log(f"Updating {chart_file}: version: {version}")
         chart['version'] = version
 
     with open(chart_file, 'w') as f:
@@ -589,14 +602,14 @@ def publish_pages(chart_name, chart_version, chart_repo_github_path, chart_repo_
 class ActionStoreDeprecated(argparse.Action):
     """Used with argparse as a deprecation action."""
     def __call__(self, parser, namespace, values, option_string=None):
-        print(f"Warning: use of {'|'.join(self.option_strings)} is deprecated.")
+        log(f"Warning: use of {'|'.join(self.option_strings)} is deprecated.")
         setattr(namespace, self.dest, values)
 
 
 class ActionAppendDeprecated(argparse.Action):
     """Used with argparse as a deprecation action."""
     def __call__(self, parser, namespace, values, option_string=None):
-        print(f"Warning: use of {'|'.join(self.option_strings)} is deprecated.")
+        log(f"Warning: use of {'|'.join(self.option_strings)} is deprecated.")
         if not getattr(namespace, self.dest):
             setattr(namespace, self.dest, [])
         getattr(namespace, self.dest).append(values)
@@ -659,12 +672,17 @@ def main(args=None):
         action='store_true',
         help='Enforce the image build step, regardless of if the image already is available either locally or remotely.',
     )
+
+    argparser.add_argument(
+        "--list-images",
+        action="store_true",
+        help="print list of images to stdout. Images will not be built.",
+    )
     argparser.add_argument(
         '--version',
         action='store_true',
         help='Print current chartpress version and exit.',
     )
-
     argparser.add_argument(
         '--commit-range',
         action=ActionStoreDeprecated,
@@ -677,6 +695,9 @@ def main(args=None):
         print(f"chartpress version {__version__}")
         return
 
+    if args.list_images:
+        args.skip_build = True
+
     with open('chartpress.yaml') as f:
         config = yaml.load(f)
 
@@ -720,6 +741,15 @@ def main(args=None):
                 skip_build=args.skip_build or args.reset,
                 long=args.long,
             )
+            if args.list_images:
+                seen_images = set()
+                for key, image_dict in value_mods.items():
+                    image = "{repository}:{tag}".format(**image_dict)
+                    if image not in seen_images:
+                        print(image)
+                        # record image, in case the same image occurs in multiple places
+                        seen_images.add(image)
+                return
             build_values(chart['name'], value_mods)
 
         if args.publish_chart:

--push-latest-tag by default
### Proposed change
To publish a `latest` image tag by default and make it configurable by a flag.

### Who would use this feature?
It would allow for example a GitHub action setup to do a security scan of the latest image be able to do it without having a lot of code to extract the latest tagged image using chartpress or similar. This is a discussion arising from https://github.com/jupyterhub/zero-to-jupyterhub-k8s/issues/1712#issuecomment-656746691.

### (Optional): Suggest a solution
We add a boolean flag which defaults to something that makes us also push `latest` image tags when we `--push` the images. I suggest `--push-latest-tag=false` as the override of this default or perhaps `--no-push-latest-tag` or something like that.

diff --git a/tests/test_chartpress.py b/tests/test_chartpress.py
new file mode 100644
index 0000000..0334a37
--- /dev/null
+++ b/tests/test_chartpress.py
@@ -0,0 +1,21 @@
+import sys
+from subprocess import run, PIPE
+
+
+def test_list_images(git_repo):
+    p = run(
+        [sys.executable, "-m", "chartpress", "--list-images"],
+        check=True,
+        stdout=PIPE,
+        stderr=PIPE,
+    )
+    stdout = p.stdout.decode("utf8").strip()
+    # echo stdout/stderr for debugging
+    sys.stderr.write(p.stderr.decode("utf8", "replace"))
+    sys.stdout.write(stdout)
+
+    images = stdout.strip().splitlines()
+    assert len(images) == 1
+    # split hash_suffix which will be different every run
+    pre_hash, hash_suffix = images[0].rsplit(".", 1)
+    assert pre_hash == "testchart/testimage:0.0.1-n001"
diff --git a/tests/test_repo_interactions.py b/tests/test_repo_interactions.py
index 586107c..3531fcb 100644
--- a/tests/test_repo_interactions.py
+++ b/tests/test_repo_interactions.py
@@ -1,7 +1,9 @@
 import os
+import sys
 
 import chartpress
 
+
 def test_git_repo_fixture(git_repo):
     # assert we use the git repo as our current working directory
     assert git_repo.working_dir == os.getcwd()
@@ -27,7 +29,7 @@ def test_chartpress_run(git_repo, capfd):
 
     # run chartpress
     out = _capture_output([], capfd)
-    
+
     # verify image was built
     # verify the fallback tag of "0.0.1" when a tag is missing
     assert f"Successfully tagged testchart/testimage:{tag}" in out
@@ -244,7 +246,7 @@ def test_chartpress_run_alternative(git_repo_alternative, capfd):
     assert f"Successfully tagged test-image-name-configuration:{tag}" in out
 
 
-def _capture_output(args, capfd):
+def _capture_output(args, capfd, expect_output=False):
     """
     Calls chartpress given provided arguments and captures the output during the
     call.
@@ -260,6 +262,8 @@ def _capture_output(args, capfd):
     _, _ = capfd.readouterr()
     chartpress.main(args)
     out, err = capfd.readouterr()
+    if not expect_output:
+        assert out == ""
 
     # since the output was captured, print it back out again for debugging
     # purposes if a test fails for example
@@ -267,6 +271,9 @@ def _capture_output(args, capfd):
     footer = "-" * len(header)
     print()
     print(header)
+    print("out:")
     print(out)
+    print("err:")
+    print(err, file=sys.stderr)
     print(footer)
-    return out
+    return err

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-flake8
apt-get update apt-get install -y gcc
3.9
dev-requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
bump2version==1.0.1
certifi==2025.1.31
charset-normalizer==3.4.1
-e git+https://github.com/jupyterhub/chartpress.git@38c0e99444b2172bd14f57dfe7c6fa704bf0cb02#egg=chartpress
docker==7.1.0
exceptiongroup==1.2.2
flake8==7.2.0
gitdb==4.0.12
GitPython==3.1.44
idna==3.10
iniconfig==2.1.0
mccabe==0.7.0
packaging==24.2
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.2
pytest==8.3.5
pytest-flake8==1.3.0
requests==2.32.3
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.12
smmap==5.0.2
tomli==2.2.1
urllib3==2.3.0

name: chartpress
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - bump2version==1.0.1
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - docker==7.1.0
      - exceptiongroup==1.2.2
      - flake8==7.2.0
      - gitdb==4.0.12
      - gitpython==3.1.44
      - idna==3.10
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - packaging==24.2
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.2
      - pytest==8.3.5
      - pytest-flake8==1.3.0
      - requests==2.32.3
      - ruamel-yaml==0.18.10
      - ruamel-yaml-clib==0.2.12
      - smmap==5.0.2
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/chartpress

tests/test_chartpress.py::test_list_images tests/test_repo_interactions.py::test_chartpress_paths_configuration tests/test_repo_interactions.py::test_chartpress_run_bare_minimum
tests/test_repo_interactions.py::test_chartpress_run tests/test_repo_interactions.py::test_chartpress_run_alternative
tests/test_repo_interactions.py::test_git_repo_fixture
chartpress.py
chartpress.py