I'm running influxdb and grafana on Docker with Windows 10.
Every time I shut down Docker, I lose my database.
Here's what I know:
Here's my yml file. Any help greatly appreciated.
version: '3'
services:
# Define an InfluxDB service
influxdb:
image: influxdb
volumes:
- ./data/influxdb:/var/lib/influxdb
ports:
- "8086:8086"
- "80:80"
- "8083:8083"
grafana:
image: grafana/grafana
volumes:
- ./data/grafana:/var/lib/grafana
container_name: grafana
ports:
- "3000:3000"
env_file:
- 'env.grafana'
links:
- influxdb
# Define a service for using the influx CLI tool.
# docker-compose run influxdb-cli
influxdb-cli:
image: influxdb
entrypoint:
- influx
- -host
- influxdb
links:
- influxdb
If you are using docker-compose down/up
, keep in mind that this is not a "restart" because:
docker-compose up
creates new containers anddocker-compose down
removes them :docker-compose up
Builds, (re)creates, starts, and attaches to containers for a service.
docker-compose down
Stops containers and removes containers, networks, volumes, and images created by up.
So, removing the containers
+ not using a mechanism to persist data
(such as volumes) means that you lose your data ☹️
On the other hand, if you keep using:
docker-compose start
docker-compose stop
docker-compose restart
you deal with the same containers, the ones created when you ran docker-compose up
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With