Skip to content

Repository files navigation

clang-tools-docker

Docker Pulls Docker Image Size Docker Scout ci part of cpp-linter

Docker images with Ubuntu's clang-format and clang-tidy packages, tagged by LLVM major version.

Website · Docker Hub · Get started · Discussions

Quick start

docker pull xianpengshen/clang-tools:21
docker run --rm -v "$PWD":/src xianpengshen/clang-tools:21 clang-format --dry-run --Werror /src/main.cpp

Usage

Docker run image

# Check clang-format version
$ docker run xianpengshen/clang-tools:19 clang-format --version
Ubuntu clang-format version 19.1.7 (20ubuntu4)
# Format code (helloworld.c in the demo directory)
$ docker run -v $PWD:/src xianpengshen/clang-tools:19 clang-format -i helloworld.c

# Check clang-tidy version
$ docker run xianpengshen/clang-tools:19 clang-tidy --version
Ubuntu LLVM version 19.1.7
  Optimized build.

# Diagnostic code (helloworld.c in the demo directory)
$ docker run -v $PWD:/src xianpengshen/clang-tools:19 clang-tidy helloworld.c \
'-checks=boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-cplusplus-*,clang-analyzer-*,cppcoreguidelines-*'

As base image in a Dockerfile

demo/Dockerfile:

FROM xianpengshen/clang-tools:17

WORKDIR /src

COPY . .

CMD [ "" ]

Then build and run the Docker image:

$ docker build -t clang-tools .

# Check clang-format version
$ docker run clang-tools clang-format --version
Ubuntu clang-format version 17.0.6 (9ubuntu1)
# Format code
$ docker run clang-tools clang-format -i helloworld.c

# Check clang-tidy version
$ docker run clang-tools clang-tidy --version
Ubuntu LLVM version 17.0.6
  Optimized build.
# Diagnostic code
$ docker run clang-tools clang-tidy helloworld.c \
'-checks=boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-cplusplus-*,clang-analyzer-*,cppcoreguidelines-*'

Supported tags and Dockerfile links

All images listed here support linux/amd64 and linux/arm64 platforms.

You can access all available Clang Tools Docker images via Docker Hub registry or GitHub Packages registry.

  • all (versions 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9; run them as clang-format-21, clang-tidy-21 and so on)
  • 22
  • 21
  • 20
  • 19
  • 18
  • 17
  • 16
  • 15
  • 14
  • 13
  • 12
  • 11
  • 10
  • 9
  • 8
  • 7
  • 16-alpine to 22-alpine: all seven carry clang-format and clang-tidy 16.0.6 from Alpine 3.18, whatever the number in the tag. For any other version, use the tag without -alpine.

Supply chain security

All images are signed with cosign (keyless, via GitHub Actions OIDC) and come with an SBOM (Software Bill of Materials, SPDX format) generated by Syft. They also carry a SLSA provenance attestation from the build.

Verify image signature

cosign verify \
  --certificate-identity-regexp 'https://github.com/cpp-linter/clang-tools-docker/.github/workflows/CI.yml@refs/heads/main' \
  --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
  xianpengshen/clang-tools:22

Download SBOM and provenance

docker buildx imagetools inspect xianpengshen/clang-tools:22 --format '{{ json .SBOM }}'
docker buildx imagetools inspect xianpengshen/clang-tools:22 --format '{{ json .Provenance }}'

Contributing

See the contributing guide and open an issue for bugs and feature requests.

License

This project is licensed under the Apache License 2.0 with LLVM Exceptions.

About

🐳 Clang Tools Docker image includes the clang-format and clang-tidy.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

15 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages