​
DirectorySecurity Advisories
Sign In
Directory
chainguard-base logo

chainguard-base

Last changed

Sign In for Updates

Get notified of upcoming product changes, critical vulnerability notifications and patches and more.

Sign In
Versions
Overview
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Chainguard Image for chainguard-base

Minimal image useful as a base for building secure images.

Chainguard Images are regularly-updated, minimal container images with low-to-zero CVEs.

Download this Image

This image is available on cgr.dev:

docker pull cgr.dev/ORGANIZATION/chainguard-base:latest

Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard registry.

Compatibility Notes

chainguard-base is comparable to other common base images, like alpine, debian, or ubuntu, with the following differences:

  • Like all other Chainguard Images, chainguard-base features a stripped down, minimal design
  • This base image comes with apk and BusyBox and reports as being a Chainguard image.
  • It has few-to-zero CVEs
  • It does not run as the root user

Getting Started

The chainguard-base image includes a shell and package manager, making it useful for installing an application’s OS-level dependencies. The image will start in a shell by default:

docker run -it cgr.dev/ORGANIZATION/chainguard-base
30d670f520ad:/#

You can run commands from within the shell like this, or you can run commands directly on your local machine without opening a shell:

docker run cgr.dev/ORGANIZATION/chainguard-base ps
PID   USER 	TIME  COMMAND
	1 root  	0:00 ps

This image is commonly used in Dockerfiles, as in the following example:

FROM cgr.dev/ORGANIZATION/chainguard-base

RUN apk update && apk add redis

ENTRYPOINT ["/usr/bin/redis-server"]

This example Dockerfile will update apk and install the Redis server onto the base image.

You could use a Dockerfile like this to build a new image:

docker build -t myredis --progress plain --no-cache .
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 152B done
#1 DONE 0.0s

#2 [internal] load metadata for cgr.dev/chainguard.edu/chainguard-base:latest
#2 DONE 0.0s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/2] FROM cgr.dev/chainguard.edu/chainguard-base:latest
#4 DONE 0.0s

#5 [2/2] RUN apk update && apk add redis
#5 0.111 fetch https://packages.cgr.dev/extras/x86_64/APKINDEX.tar.gz
#5 5.625 fetch https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz
#5 6.824  [https://packages.cgr.dev/extras]
#5 6.824  [https://packages.wolfi.dev/os]
#5 6.824 OK: 87589 distinct packages available
#5 7.139 (1/5) Installing ncurses-terminfo-base (6.5_p20240629-r0)
#5 7.294 (2/5) Installing ncurses (6.5_p20240629-r0)
#5 7.515 (3/5) Installing bash (5.2.37-r1)
#5 7.746 (4/5) Installing posix-libc-utils (2.40-r2)
#5 7.911 (5/5) Installing redis-7.4 (7.4.1-r0)
#5 8.346 OK: 22 MiB in 20 packages
#5 DONE 8.4s

#6 exporting to image
#6 exporting layers 0.0s done
#6 writing image sha256:f7b9c568bce1a0eedc04ed5ee56b3e20669c9d7b2f544d396dff5dd247745a50 done
#6 naming to docker.io/library/myredis2 done
#6 DONE 0.1s

Following that, you can run the new image built from the chainguard-base image.

docker run myredis

Configuration

The chainguard-base image uses the ash shell from BusyBox by default.

If you need to port a bash and Debian centric entrypoint script to Chainguard Images, you can update your scripts to work in ash. Alternatively, you can install the shell that works with your scripts.

For example:

docker run -it cgr.dev/ORGANIZATION/chainguard-base
e9804f9b1ca9:/# echo {1..5}
{1..5}

e9804f9b1ca9:/# apk add bash
fetch https://packages.wolfi.dev/os/aarch64/APKINDEX.tar.gz
(1/3) Installing ncurses-terminfo-base (6.4_p20231125-r1)
(2/3) Installing ncurses (6.4_p20231125-r1)
(3/3) Installing bash (5.2.21-r1)
OK: 20 MiB in 17 packages

e9804f9b1ca9:/# bash

e9804f9b1ca9:/# echo {1..5}
1 2 3 4 5

e9804f9b1ca9:/#

Oftentimes, you’ll often need to install extra utilities to provide required dependencies for applications and scripts. These dependencies are likely to have different package names compared to other Linux distributions, so the apk search command can be very useful for finding the package you need.

For example, say you are porting a Dockerfile that uses the groupadd command. You could convert this to the BusyBox addgroup equivalent, but it’s also perfectly fine to add the groupadd utility. The only issue is that there’s no groupadd package, so you will have to search for it:

e9804f9b1ca9:/# groupadd
/bin/sh: groupadd: not found

e9804f9b1ca9:/# apk add groupadd
ERROR: unable to select packages:
  groupadd (no such package):
	required by: world[groupadd]

e9804f9b1ca9:/# apk update
fetch https://packages.cgr.dev/extras/x86_64/APKINDEX.tar.gz
fetch https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz
 [https://packages.cgr.dev/extras]
 [https://packages.wolfi.dev/os]

e9804f9b1ca9:/# apk search groupadd
shadow-4.15.1-r0

e9804f9b1ca9:/# apk add shadow
(1/4) Installing libmd (1.1.0-r1)
(2/4) Installing libbsd (0.12.2-r0)
(3/4) Installing linux-pam (1.6.1-r0)
(4/4) Installing shadow (4.15.1-r0)
OK: 20 MiB in 18 packages

e9804f9b1ca9:/# groupadd
Usage: groupadd [options] GROUP

Options:
  -f, --force               	exit successfully if the group already exists,
                            	and cancel -g if the GID is already used
  -g, --gid GID             	use GID for the new group
  -h, --help                	display this help message and exit
  -K, --key KEY=VALUE       	override /etc/login.defs defaults
  -o, --non-unique          	allow to create groups with duplicate
                            	(non-unique) GID
  -p, --password PASSWORD   	use this encrypted password for the new group
  -r, --system              	create a system account
  -R, --root CHROOT_DIR     	directory to chroot into
  -P, --prefix PREFIX_DIR   	directory prefix
  -U, --users USERS         	list of user members of this group

Another useful trick is the cmd: syntax for finding packages that provide commands. For example, searching for ldd returns multiple results:

e9804f9b1ca9:/# apk search ldd
dpkg-dev-1.22.6-r0
nfs-utils-2.6.4-r1
posix-libc-utils-2.39-r1

But if you use the cmd: syntax it will only return a single result:

e9804f9b1ca9:/# apk search cmd:ldd
posix-libc-utils-2.39-r1

You can even use the syntax directly in apk add:

e9804f9b1ca9:/# apk add cmd:ldd
(1/4) Installing ncurses-terminfo-base (6.4_p20231125-r1)
(2/4) Installing ncurses (6.4_p20231125-r1)
(3/4) Installing bash (5.2.21-r1)
(4/4) Installing posix-libc-utils (2.39-r1)
OK: 27 MiB in 22 packages

Documentation and Resources

The following resources provide helpful information on working with Chainguard's base images. Note that some of these resources focus on the wolfi-base image — the free-tier alternative to the chainguard-base image — but these same principles and practices apply to chainguard-base.

Contact Support

If you have a Zendesk account (typically set up for you by your Customer Success Manager) you can reach out to Chainguard's Customer Success team through our Zendesk portal.

What are Chainguard Images?

Chainguard Images are a collection of container images designed for security and minimalism.

Many Chainguard Images are distroless; they contain only an open-source application and its runtime dependencies. These images do not even contain a shell or package manager. Chainguard Images are built with Wolfi, our Linux undistro designed to produce container images that meet the requirements of a secure software supply chain.

The main features of Chainguard Images include:

-dev Variants

As mentioned previously, Chainguard’s distroless Images have no shell or package manager by default. This is great for security, but sometimes you need these things, especially in builder images. For those cases, most (but not all) Chainguard Images come paired with a -dev variant which does include a shell and package manager.

Although the -dev image variants have similar security features as their distroless versions, such as complete SBOMs and signatures, they feature additional software that is typically not necessary in production environments. The general recommendation is to use the -dev variants only to build the application and then copy all application artifacts into a distroless image, which will result in a final container image that has a minimal attack surface and won’t allow package installations or logins.

That being said, it’s worth noting that -dev variants of Chainguard Images are completely fine to run in production environments. After all, the -dev variants are still more secure than many popular container images based on fully-featured operating systems such as Debian and Ubuntu since they carry less software, follow a more frequent patch cadence, and offer attestations for what they include.

Learn More

To better understand how to work with Chainguard Images, we encourage you to visit Chainguard Academy, our documentation and education platform.

Licenses

Chainguard Images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" version of this image:

  • Apache-2.0

  • GCC-exception-3.1

  • GPL-2.0-only

  • GPL-2.0-or-later

  • GPL-3.0-or-later

  • LGPL-2.1-or-later

  • MIT

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Compliance

A FIPS validated version of this image is available for FedRAMP compliance. STIG is included with FIPS image.


Related images

Category
base

Safe Source for Open Sourceâ„¢
Media KitContact Us
© 2024 Chainguard. All Rights Reserved.
Private PolicyTerms of Use

Product

Chainguard Images