Need to understand how to use multiple images in a single service in docker-compose file.
Consider the following docker-compose file,
version: '3.4'
services:
postgres:
image: timescale/timescaledb:latest-pg14
restart: always
environment:
- POSTGRES_USER=xxxx
- POSTGRES_PASSWORD=xxxx
logging:
options:
max-size: 10m
max-file: "3"
ports:
- '5432:5432'
volumes:
- ./postgres-data:/var/lib/postgresql/data
- ./sql/historydb.sql:/docker-entrypoint-initdb.d/historydb.sql
app:
image: xxxxxxxxxxxxxx:xx.xx.xx.xx
network_mode: host
volumes:
- ./sample:/var/sample
As you can see from the above example, we have two services (postgres and app).
Now we want to merge these two services into one (say, mergedapp). So that we have a service like following,
version: '3.4'
services:
mergedapp:
image: timescale/timescaledb:latest-pg14
image: xxxxxxxxxxxxxx:xx.xx.xx.xx
restart: always
network_mode: host
environment:
- POSTGRES_USER=xxxx
- POSTGRES_PASSWORD=xxxx
logging:
options:
max-size: 10m
max-file: "3"
ports:
- '5432:5432'
volumes:
- ./postgres-data:/var/lib/postgresql/data
- ./sql/historydb.sql:/docker-entrypoint-initdb.d/historydb.sql
- ./sample:/var/sample
I know the above docker-compose content is not valid. Hence, I need some docker-compose file content that will satisfy my requirement.
Please help.
Tried the following but it does not work,
version: '3.4'
services:
mergedapp:
image: timescale/timescaledb:latest-pg14
image: xxxxxxxxxxxxxx:xx.xx.xx.xx
restart: always
network_mode: host
environment:
- POSTGRES_USER=xxxx
- POSTGRES_PASSWORD=xxxx
logging:
options:
max-size: 10m
max-file: "3"
ports:
- '5432:5432'
volumes:
- ./postgres-data:/var/lib/postgresql/data
- ./sql/historydb.sql:/docker-entrypoint-initdb.d/historydb.sql
- ./sample:/var/sample