Skip to content

Instantly share code, notes, and snippets.

@beldpro-ci
Last active April 29, 2017 15:02
Show Gist options
  • Save beldpro-ci/5fc01c0e7cc884bcf769e5ee4bf925b8 to your computer and use it in GitHub Desktop.
Save beldpro-ci/5fc01c0e7cc884bcf769e5ee4bf925b8 to your computer and use it in GitHub Desktop.
Use of `build` directive to build sample postgres database
# Make a directory `db` encapsulates your image, having
# a docker-compose at the same level.
$ tree
.
├── db
│ ├── Dockerfile
│ └── init
│ └── 01-filladb.sh
└── docker-compose.yml
2 directories, 3 files
# in the docker-compose file, reference the image directory
# in the `build` property. This makes `docker-compose` build
# the directory as an image and then use it when creating
# containers.
$ cat docker-compose.yml
version: '3.2'
services:
postgres:
restart: 'always'
ports:
- '5432:5432'
environment:
- "FILLA_DB_USER=filla"
- "FILLA_DB_PASSWORD=filla"
- "FILLA_DB_DATABASE=filladb1"
- "POSTGRES_PASSWORD=password"
build: './db'
networks:
infranet:
aliases:
- 'postgres'
networks:
infranet:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment