-
Notifications
You must be signed in to change notification settings - Fork 11
/
docker-compose.yml
51 lines (44 loc) · 2.32 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# A Docker Compose must always start with the version tag.
# We use '3' because it's the last version.
version: "3.8"
# You should know that Docker Compose works with services.
# 1 service = 1 container.
# For example, a service, a server, a client, a database...
# We use the keyword 'services' to start to create services.
services:
# The name of our service is "database"
# but you can use the name of your choice.
# Note: This may change the commands you are going to use a little bit.
database:
# Official Postgres image from DockerHub (we use the last version)
image: "postgres:latest"
# By default, a Postgres database is running on the 5432 port.
# If we want to access the database from our computer (outside the container),
# we must share the port with our computer's port.
# The syntax is [port we want on our machine]:[port we want to retrieve in the container]
# Note: You are free to change your computer's port,
# but take into consideration that it will change the way
# you are connecting to your database.
ports:
- 5432:5432
environment:
POSTGRES_USER: jdr # The PostgreSQL user (useful to connect to the database)
POSTGRES_PASSWORD: password # The PostgreSQL password (useful to connect to the database)
POSTGRES_DB: jdr # The PostgreSQL default database (automatically created at first launch)
####
## If you want to use a `.env` file, please comment the `environment` section.
####
# The `env_file` tag allows us to declare an environment file
#env_file:
# - .env # The name of your environment file (the one at the repository root)
####
## If you want to persist the database data, please uncomment the lines below.
####
# The `volumes` tag allows us to share a folder with our container.
# Its syntax is as follows: [folder path on our machine]:[folder path to retrieve in the container]
volumes:
# In this example, we share the folder `db-data` in our root repository, with the default PostgreSQL data path.
# It means that every time the repository is modifying the data inside
# of `/var/lib/postgresql/data/`, automatically the change will appear in `db-data`.
# You don't need to create the `db-data` folder. Docker Compose will do it for you.
- ./db-data/:/var/lib/postgresql/data/