Skip to content

Easy docker health checks, /healthz endpoints, and container delays

Notifications You must be signed in to change notification settings

marcinpraczko/goss-docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Goss Docker container

Dockerfiles

Goss

Not sure what Goss is, read these:

  • Goss - Project page
  • Blog post - Examples on how these Goss images can be used

Using the base image

This is a simple alpine image with Goss preinstalled on it. Can be used as a base image for your projects to allow for easy health checking.

Mount example

Create the container

docker run --name goss aelsabbahy/goss goss

Create your container and mount goss

docker run --rm -it --volumes-from goss --name weby nginx

Run goss inside your container

docker exec weby /goss/goss autoadd nginx

HEALTHCHECK example

FROM aelsabbahy/goss:latest

COPY goss/ /goss/
HEALTHCHECK --interval=1s --timeout=6s CMD goss -g /goss/goss.yaml validate

# your stuff..

Startup delay example

FROM aelsabbahy/goss:latest

COPY goss/ /goss/

# Alternatively, the -r option can be set
# using the GOSS_RETRY_TIMEOUT env variable
CMD goss -g /goss/goss.yaml validate -r 5m && exec real_comand..

Using the onbuild image

Create a goss/goss.yaml file and optionally a checks folder in the following structure:

.
|-- Dockerfile
`-- goss/
    |-- checks/
    |   `-- db_login.sh
    `-- goss.yaml

In your Dockerfile use the onbuild container as follows:

Serve a healthz endpoint

FROM aelsabbahy/goss:onbuild
CMD ["serve"]

Run tests until they pass or we timeout

FROM aelsabbahy/goss:onbuild
CMD ["validate", "--retry-timeout", "5m", "--sleep", "10s"]

About

Easy docker health checks, /healthz endpoints, and container delays

Resources

Stars

Watchers

Forks

Packages

No packages published