Here a simple docker-compose.yml file to get kong community up and running. It is configured to use postgresql that persists data to a local docker volume. All ports are mapped to localhost only and log goes to stdout/stderr.
version: '3.4' services: kong-db: image: 'postgres:10.1' ports: - 127.0.0.1:5432:5432 environment: POSTGRES_USER: kong POSTGRES_PASSWORD: kong POSTGRES_DB: kong PGDATA: /var/lib/postgresql/data/pgdata volumes: - db-volume:/var/lib/postgresql/data/pgdata healthcheck: test: 'echo "select 1" | psql -U kong kong || exit 1' interval: 1m timeout: 3s retries: 3 restart: unless-stopped kong: image: 'kong:0.11.2' ports: - 127.0.0.1:8000:8000 - 127.0.0.1:8443:8443 - 127.0.0.1:8001:8001 - 127.0.0.1:8444:8444 environment: KONG_DATABASE: postgres KONG_PG_HOST: kong-db KONG_PG_DATABASE: kong KONG_PG_USER: kong KONG_PG_PASSWORD: kong KONG_PROXY_ACCESS_LOG: /dev/stdout KONG_ADMIN_ACCESS_LOG: /dev/stdout KONG_PROXY_ERROR_LOG: /dev/stderr KONG_ADMIN_ERROR_LOG: /dev/stderr links: - kong-db # uncomment following line to run migrations for a new database # command: kong migrations up -v depends_on: - kong-db healthcheck: test: 'curl -f http://localhost:8001/status || exit 1' interval: 1m timeout: 3s retries: 3 restart: unless-stopped volumes: db-volume:
Attention: The kong container fails to start unless migrations are not run on the connected database. To do this simply uncomment the marked line and start the containers. With the command set the container will execute database migrations and stop with exit code 0. After that the line can be commented out again. Then you can start kong with the given file.