This is a Docker skeleton project that can be used to quickly get a new cisagov GitHub Docker project started. This skeleton project contains licensing information, as well as pre-commit hooks and GitHub Actions configurations appropriate for Docker containers and the major languages that we use.
To run the cisagov/example
image via Docker:
docker run cisagov/example:0.0.1
-
Create a
docker-compose.yml
file similar to the one below to use Docker Compose.--- version: "3.7" services: example: image: cisagov/example:0.0.1 volumes: - type: bind source: <your_log_dir> target: /var/log environment: - ECHO_MESSAGE="Hello from docker-compose" ports: - target: 8080 published: 8080 protocol: tcp
-
Start the container and detach:
docker-compose up --detach
This container also supports passing sensitive values via Docker secrets. Passing sensitive values like your credentials can be more secure using secrets than using environment variables. See the secrets section below for a table of all supported secret files.
-
To use secrets, create a
quote.txt
file containing the values you want set:Better lock it in your pocket.
-
Then add the secret to your
docker-compose.yml
file:--- version: "3.7" secrets: quote_txt: file: quote.txt services: example: image: cisagov/example:0.0.1 volumes: - type: bind source: <your_log_dir> target: /var/log environment: - ECHO_MESSAGE="Hello from docker-compose" ports: - target: 8080 published: 8080 protocol: tcp secrets: - source: quote_txt target: quote.txt
-
Pull the new image from Docker Hub:
docker-compose pull
-
Recreate the running container by following the previous instructions:
docker-compose up --detach
-
Stop the running container:
docker stop <container_id>
-
Pull the new image:
docker pull cisagov/example:0.0.1
-
Recreate and run the container by following the previous instructions.
The images of this container are tagged with semantic
versions of the underlying example project that they
containerize. It is recommended that most users use a version tag (e.g.
:0.0.1
).
Image:tag | Description |
---|---|
cisagov/example:1.2.3 |
An exact release version. |
cisagov/example:1.2 |
The most recent release matching the major and minor version numbers. |
cisagov/example:1 |
The most recent release matching the major version number. |
cisagov/example:edge |
The most recent image built from a merge into the develop branch of this repository. |
cisagov/example:nightly |
A nightly build of the develop branch of this repository. |
cisagov/example:latest |
The most recent release image pushed to a container registry. Pulling an image using the :latest tag should be avoided. |
See the tags tab on Docker Hub for a list of all the supported tags.
Mount point | Purpose |
---|---|
/var/log |
Log storage |
The following ports are exposed by this container:
Port | Purpose |
---|---|
8080 | Example only; nothing is actually listening on the port |
The sample Docker composition publishes the exposed port at 8080.
There are no required environment variables.
Name | Purpose | Default |
---|---|---|
ECHO_MESSAGE |
Sets the message echoed by this container. | Hello World from Dockerfile |
Filename | Purpose |
---|---|
quote.txt |
Replaces the secret stored in the example library's package data. |
Build the image locally using this git repository as the build context:
docker build \
--build-arg VERSION=0.0.1 \
--tag cisagov/example:0.0.1 \
https://github.com/cisagov/example.git#develop
To create images that are compatible with other platforms, you can use the
buildx
feature of
Docker:
-
Copy the project to your machine using the
Code
button above or the command line:git clone https://github.com/cisagov/example.git cd example
-
Create the
Dockerfile-x
file withbuildx
platform support:./buildx-dockerfile.sh
-
Build the image using
buildx
:docker buildx build \ --file Dockerfile-x \ --platform linux/amd64 \ --build-arg VERSION=0.0.1 \ --output type=docker \ --tag cisagov/example:0.0.1 .
Please see our Project Setup guide for step-by-step instructions on how to start a new repository from a skeleton. This will save you time and effort when configuring a new repository!
We welcome contributions! Please see CONTRIBUTING.md
for
details.
This project is in the worldwide public domain.
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.