Home Explore Blog CI



docker

3rd chunk of `content/manuals/build/ci/_index.md`
89a73b45022c696536195d9b4485bb1e3eeabed1c1916e9b000000010000082e


There are several uses for Docker at this stage of development, even if you
don't end up packaging your application as a container image.

## Docker as a build environment

Containers are reproducible, isolated environments that yield predictable
results. Building and testing your application in a Docker container makes it
easier to prevent unexpected behaviors from occurring. Using a Dockerfile, you
define the exact requirements for the build environment, including programming
runtimes, operating system, binaries, and more.

Using Docker to manage your build environment also eases maintenance. For
example, updating to a new version of a programming runtime can be as simple as
changing a tag or digest in a Dockerfile. No need to SSH into a pet VM to
manually reinstall a newer version and update the related configuration files.

Additionally, just as you expect third-party open source packages to be secure,
the same should go for your build environment. You can scan and index a builder
image, just like you would for any other containerized application.

The following links provide instructions for how you can get started using
Docker for building your applications in CI:

- [GitHub Actions](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action)
- [GitLab](https://docs.gitlab.com/runner/executors/docker.html)
- [Circle CI](https://circleci.com/docs/using-docker/)
- [Render](https://render.com/docs/docker)

### Docker in Docker

You can also use a Dockerized build environment to build container images using
Docker. That is, your build environment runs inside a container which itself is
equipped to run Docker builds. This method is referred to as "Docker in Docker".

Docker provides an official [Docker image](https://hub.docker.com/_/docker)
that you can use for this purpose.

## What's next

Docker maintains a set of official GitHub Actions that you can use to build,
annotate, and push container images on the GitHub Actions platform. See
[Introduction to GitHub Actions](github-actions/_index.md) to learn more and
get started.

Title: Docker as a Build Environment in CI/CD
Summary
This section details the benefits of using Docker as a build environment in continuous integration, emphasizing reproducibility, isolation, and predictable results. It explains how Dockerfiles allow defining precise build requirements, easing maintenance, and enhancing security by enabling the scanning and indexing of builder images. The passage also highlights the 'Docker in Docker' approach for building container images within a Dockerized build environment and suggests official Docker images for this purpose. It concludes by pointing to Docker's official GitHub Actions for building, annotating, and pushing container images on the GitHub Actions platform, directing the reader to an introduction on GitHub Actions for more information.