From f6ba17dfc7a4c5e516f970d795851b4a8cf0bbbc Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Wed, 9 Mar 2016 12:20:20 -0500 Subject: [PATCH] README: Update Docker Compose instructions --- README.md | 45 ++++++++++++++++++--------------------------- docker-compose.yml | 4 ++-- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 99506eb8..c91051d4 100644 --- a/README.md +++ b/README.md @@ -41,48 +41,39 @@ Clair detects some vulnerabilities and sends a webhook to your continuous deploy ## Hello Heartbleed -### Requirements - -All instructions assume the user has already setup the following: - -- A running instance of [PostgreSQL] 9.4+ - During the first run, Clair will bootstrap its database with vulnerability data from its data sources. It can take several minutes before the database has been fully populated. -[PostgreSQL]: http://postgresql.org - -### Docker +### Docker Compose -The easiest way to get an instance of Clair running is to simply pull down the latest copy from Quay. +The easiest way to get an instance of Clair running is to use Docker Compose to run everything locally. +This runs a PostgreSQL database insecurely and locally in a container. +This method should only be used for testing. ```sh +$ curl -L https://raw.githubusercontent.com/coreos/clair/master/docker-compose.yml -o $HOME/docker-compose.yml $ mkdir $HOME/clair_config $ curl -L https://raw.githubusercontent.com/coreos/clair/master/config.example.yaml -o $HOME/clair_config/config.yaml -$ $EDITOR $HOME/clair_config/config.yaml # Add the URI for your postgres database -$ docker run -p 6060-6061:6060-6061 -v $HOME/clair_config:/config quay.io/coreos/clair -config=/config/config.yaml +$ $EDITOR $HOME/clair_config/config.yaml # Edit database source to be postgresql://postgres:password@postgres:5432?sslmode=disable +$ docker-compose -f $HOME/docker-compose.yml up -d ``` -### Docker Compose +Docker Compose may start Clair before Postgres which will raise an error. +If this error is raised, manually execute `docker start clair_clair`. + + +### Docker + +This method assumes you already have a [PostgreSQL 9.4+] database running. +This is the recommended method for production deployments. -Or, You can run an instance of Clair and PosrgreSQL using a docker-compose. +[PostgreSQL 9.4+]: http://postgresql.org ```sh -$ curl -L https://raw.githubusercontent.com/coreos/clair/master/docker-compose.yml -o $HOME/docker-compose.yml -$ $EDITOR $HOME/docker-compose.yml # Edit POSTGRES_PASSWORD. $ mkdir $HOME/clair_config $ curl -L https://raw.githubusercontent.com/coreos/clair/master/config.example.yaml -o $HOME/clair_config/config.yaml -$ $EDITOR $HOME/clair_config/config.yaml # Add the URI for your postgres database. (see example below) --- -database: - # PostgreSQL Connection string - # http://www.postgresql.org/docs/9.4/static/libpq-connect.html - source: postgresql://postgres:@postgres:5432?sslmode=disable --- -$ docker-compose -f $HOME/docker-compose.yml up -d -# if execution of Clair has failed, please try to re-start. -# it will fail when Clair is started before the PostgreSQL start a service. -# $ docker start clair_clair +$ $EDITOR $HOME/clair_config/config.yaml # Add the URI for your postgres database +$ docker run -p 6060-6061:6060-6061 -v $HOME/clair_config:/config quay.io/coreos/clair -config=/config/config.yaml ``` ### Source diff --git a/docker-compose.yml b/docker-compose.yml index 8d3628e3..fd8411db 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: container_name: clair_postgres image: postgres:latest environment: - POSTGRES_PASSWORD: + POSTGRES_PASSWORD: password clair: container_name: clair_clair @@ -14,7 +14,7 @@ services: ports: - "6060-6061:6060-6061" links: - - postgres + - postgres volumes: - /tmp:/tmp - ./clair_config:/config