It looks like there are some problems with the volume configuration in your Grafana container:

First, I think this was simply a typo in your question:

      - grafana_ini:/etc/grafana/grafana.inianticipated location in container

I suspect that you were actually intending this:

      - grafana_ini:/etc/grafana/grafana.ini

Which doesn't make any sense: grafana.ini is a file, but a volume is a directory. Docker won't allow you to mount a directory on top of a file, hence the error:

ERROR: .../etc/grafana/grafana.ini is not directory

You have the same problem with the grafana_data volume, which you're attempting to mount on top of datasource.yml:

      - grafana_data:/etc/grafana/provisioning/datasources/datasource.yml

I think you may be approaching this configuration in the wrong way; you may want to read through these documents:

  • https://grafana.com/docs/grafana/latest/installation/docker/
  • https://grafana.com/docs/grafana/latest/administration/configure-docker/
  • https://grafana.com/docs/grafana/latest/administration/provisioning/

It is possible to configure Grafana (and Prometheus!) using only bind mounts and environment variables (this includes installing plugin, data sources, and dashboards), so you don't need to build your own custom images.


Unrelated to this particular problem, there are some other things in your docker-compose.yml that are worth changing. You should no longer be using the links directive...

    links:
      - prometheus

...because Docker maintains DNS for you automatically; your containers can refer to each other by name with no additional configuration.

Answer from larsks on Stack Overflow
🌐
Grafana
grafana.com › docs › grafana › latest › setup-grafana › installation › docker
Run Grafana Docker image | Grafana documentation
Add the following code into the docker-compose.yaml file. ... services: grafana: image: grafana/grafana-enterprise container_name: grafana restart: unless-stopped ports: - '3000:3000' volumes: - grafana-storage:/var/lib/grafana volumes: grafana-storage: {}
🌐
Grafana
grafana.com › docs › grafana › latest › setup-grafana › configure-docker
Configure a Grafana Docker image | Grafana documentation
To increase the log level to DEBUG mode, add the environment variable GF_LOG_LEVEL to the docker-compose.yaml file. ... version: '3.8' services: grafana: image: grafana/grafana-enterprise container_name: grafana restart: unless-stopped environment: # increases the log level from info to debug - GF_LOG_LEVEL=debug ports: - '3000:3000' volumes: - 'grafana_storage:/var/lib/grafana' volumes: grafana_storage: {}
Discussions

Grafana on Docker - Stack Overflow
I am using docker to run prometheus, grafana and node exporter. I am trying to use named volumes and I am having some issues with that. My docker-compose code is: version: "3.7" volumes: ... More on stackoverflow.com
🌐 stackoverflow.com
How can I store data with Docker Compose containers? - Stack Overflow
What's the proper way to store the created volumes and reusing them with commands up/down, so even when recreating the containers? I must use some sort of backup methods provided by every image (so, for example, a DB export for Postgres, and some other type of export for Grafana), or there is a way to do this inside docker-compose... More on stackoverflow.com
🌐 stackoverflow.com
Running Grafana as Docker, but doesn't remember my changes if I restart the container
You need persistent storage for your containerized grafana configuration. More on reddit.com
🌐 r/docker
28
16
January 24, 2021
What volumes should I mount when using Docker? - Grafana - Grafana Labs Community Forums
First of all, the documentation I’m reading for Docker setup is really really bad: Run Grafana Docker image | Grafana Labs Docker | Grafana Labs Basically there’s VERY little mention of how to set up the bind mounts / volume mounts for data persistence here. I’m simply using Docker Compose to ... More on community.grafana.com
🌐 community.grafana.com
1
January 31, 2021
🌐
Medium
medium.com › swlh › easy-grafana-and-docker-compose-setup-d0f6f9fcec13
Easy Grafana and Docker-Compose Setup | by Graham Bryan | The Startup | Medium
December 20, 2021 - To create this volume, ... I am assuming a user already has or knows how to create a json model for the dashboard and add a data source. If you do not, you can still follow the setup and create your own dashboard later! There are three things we add to the docker image: provisioning, grafana.ini, and dashboards.
🌐
GitHub
github.com › stefanwalther › docker-grafana › blob › master › docker-compose.yml
docker-grafana/docker-compose.yml at master · stefanwalther/docker-grafana
volumes: grafana_data: {} · networks: front-tier: driver: bridge · back-tier: driver: bridge · · services: · grafana: # image: stefanwalther/grafana · build: context: ./ dockerfile: Dockerfile · # container_name: grafana ·
Author: stefanwalther
Top answer
1 of 2
3

It looks like there are some problems with the volume configuration in your Grafana container:

First, I think this was simply a typo in your question:

      - grafana_ini:/etc/grafana/grafana.inianticipated location in container

I suspect that you were actually intending this:

      - grafana_ini:/etc/grafana/grafana.ini

Which doesn't make any sense: grafana.ini is a file, but a volume is a directory. Docker won't allow you to mount a directory on top of a file, hence the error:

ERROR: .../etc/grafana/grafana.ini is not directory

You have the same problem with the grafana_data volume, which you're attempting to mount on top of datasource.yml:

      - grafana_data:/etc/grafana/provisioning/datasources/datasource.yml

I think you may be approaching this configuration in the wrong way; you may want to read through these documents:

  • https://grafana.com/docs/grafana/latest/installation/docker/
  • https://grafana.com/docs/grafana/latest/administration/configure-docker/
  • https://grafana.com/docs/grafana/latest/administration/provisioning/

It is possible to configure Grafana (and Prometheus!) using only bind mounts and environment variables (this includes installing plugin, data sources, and dashboards), so you don't need to build your own custom images.


Unrelated to this particular problem, there are some other things in your docker-compose.yml that are worth changing. You should no longer be using the links directive...

    links:
      - prometheus

...because Docker maintains DNS for you automatically; your containers can refer to each other by name with no additional configuration.

2 of 2
0

Another problem that can cause a similar error, is when mixing up the file name extensions. Be mindful to not refer to them as .yaml in the docker-compose.yml file, when you've actually used .yml. Or vice versa.

For example, you have the following file:

  • grafana_datasources.yml

Then don't do (.yaml):

./evidently_service/config/grafana_datasources.yaml:/etc/grafana/provisioning/datasources/grafana_datasources.yaml

Do this instead (.yml):

./evidently_service/config/grafana_datasources.yml:/etc/grafana/provisioning/datasources/grafana_datasources.yml
🌐
Medium
medium.com › @syed_usman_ahmed › using-grafana-with-docker-part-2-85883d833867
Deploy Grafana latest version with Docker — Part 2 | by Syed Usman Ahmad | Medium
October 28, 2024 - Use the docker ps command to see if it is working correctly: ... 📌 NOTE: Incase if it is not available on your machine then you can follow this tutorial link, where I have explained as how to install it. ... version: '3.8' services: grafana: image: grafana/grafana-enterprise container_name: grafana restart: unless-stopped ports: - '3000:3000' volumes: - grafana_data:/var/lib/grafana volumes: grafana_data: {}y
Find elsewhere
🌐
AirTips
theairtips.com › post › setting-up-grafana-with-docker-compose
Setting up Grafana with Docker Compose - AirTips
June 22, 2023 - Next, add the following to docker-compose.yml to add Grafana: grafana: image: grafana/grafana:7.5.7 ports: - 3000:3000 restart: unless-stopped volumes: - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources - grafana-data:/var/lib/grafana volumes: grafana-data:
🌐
Reddit
reddit.com › r/docker › running grafana as docker, but doesn't remember my changes if i restart the container
r/docker on Reddit: Running Grafana as Docker, but doesn't remember my changes if I restart the container
January 24, 2021 -

Hello,

I'm running Grafana as a Docker using:

https://devconnected.com/how-to-install-influxdb-telegraf-and-grafana-on-docker/

I'm new to Docker, but I go into Grafana and setup a datasource and simple dashboard and all is ok, but if I restart the VM the container runs on or restart the docker contain instance it's as if I have just set it up as all changes are gone.

What do I need to do to save my changes?

Thanks

🌐
Grafana
community.grafana.com › t › what-volumes-should-i-mount-when-using-docker › 42445
What volumes should I mount when using Docker? - Grafana - Grafana Labs Community Forums
January 31, 2021 - First of all, the documentation I’m reading for Docker setup is really really bad: Run Grafana Docker image | Grafana Labs Docker | Grafana Labs Basically there’s VERY little mention of how to set up the bind mounts / volume mounts for data persistence here. I’m simply using Docker Compose to ...
🌐
Techdox
docs.techdox.nz › grafana
Setting Up Grafana with Docker Compose - Techdox Docs
This Docker Compose setup deploys Grafana in a Docker container, providing a powerful and flexible way to visualize and analyze your data. version: "3.8" services: grafana: image: grafana/grafana container_name: grafana restart: unless-stopped ports: - '3000:3000' volumes: - grafana-storage:/var/lib/grafana volumes: grafana-storage: {}
🌐
Grafana
community.grafana.com › configuration
New Docker Install with persistent storage, Permission problem - Configuration - Grafana Labs Community Forums
October 2, 2018 - I am starting a new Grafana docker ... error docker-compose.yml version: '3' services: grafana: image: grafana/grafana:5.2.4 volumes: - ..grafana-storage:/var/lib/grafana Error docker-compose up Starting grafana_grafana_1 ... done Attaching to grafana_grafana_1 grafana_1 | ...
🌐
Grafana
community.grafana.com › installation
Grafana 10 docker installation, with mounted volume - Installation - Grafana Labs Community Forums
June 21, 2023 - Hi, This is the first time I install Grafana, I’m not a linux expert, just trying to learn making myself a home lab, so the problem is that I’ve installed Truenas, then i created a dataset which I’m mounting in the host where I run docker, I’m using the following docker compose to install Grafana latest version: version: '3' networks: spider: external: true services: grafana_changarritos: container_name: grafana_changarritos image: grafana/grafana:latest restart: always ...
🌐
GitHub
github.com › grafana › grafana › issues › 66423
Grafana does not save data when docker host volumes are used · Issue #66423 · grafana/grafana
April 12, 2023 - What happened: When using docker compose with host volumes, the data are not created in the host folders services: grafana: image: grafana/grafana:latest container_name: grafana hostname: grafana r...
Author: grafana
🌐
Reddit
reddit.com › r/docker › migrating grafana from docker to docker-compose
r/docker on Reddit: Migrating Grafana from Docker to Docker-Compose
December 29, 2020 -

I feel like I may be missing something simple but for the life of me can't find out why. I haven't been able to successfully Google my issue so hopefully someone here has an idea.

I am trying to move all my docker containers to docker-compose, my reasonaning is it seems easier to recreate them when I upgrade the images. Having all the info in the .yml file of docker-compose seems cleaner than keeping my docker run commands in a Google Doc.

I am using a persistent volume to store the data, which I think is where my issue is coming from.

Currently, to start Grafana I run the following:

docker run -d -p 3000:3000 --name=grafana --restart=always -v grafana-storage:/var/lib/grafana grafana/grafana 

I have translated that into my docker-compose.yml file as:

  grafana:
    container_name: grafana
    image: grafana/grafana
    ports:
      - "3000:3000"
    volumes:
      - grafana-storage:/var/lib/grafana
    restart: always
    network_mode: host

I have some other services so I haven't copied the whole file but the volume: section is popoulated fine. The Grafana service comes up fine, it gets to the login screen and I can't use my regular login/password. So I am thinking it's not accessing the persistent information in the container.

I have removed the container and recreated it with docker-compose up. I have then also been able to go back to a working Grafana instance by running my old docker container again.

Am I missing a step? Thank you so much for reading this far.

**I just tried migrating Portainer and I have the same issue, no persistent storage, it's asking me to create a new user, no login screen.

*** I've also tried using the external: true command to no effect

volumes:
  home-assistant-volume:
  grafana-storage:
    external: true
  portainer_data:
    external: true

I have also followed the suggestions here: https://stackoverflow.com/questions/60148581/re-using-existing-volume-with-docker-compose

🌐
HackMD
hackmd.io › @Vatten › B1v3MLY_F
Grafana and InfluxDB in Docker
> If you wish to adapt the default configuration, use something like the following to copy it from a running grafana container: ``` $ sudo docker run --name tmp-grafana-container -d grafana $ sudo docker cp tmp-grafana-container:/etc/grafana/grafana.ini volume/grafana/conf/grafana.ini $ sudo docker cp tmp-grafana-container:/var/lib/grafana volume/grafana/data $ sudo docker rm -f tmp-grafana-container ``` ```yaml= version: '3' services: grafana: image: grafana/grafana hostname: grafana restart: always ports: - 3000:3000 volumes: - ./volume/grafana/data:/var/lib/grafana:rw - ./volume/grafana/conf/grafana.ini:/etc/grafana/grafana.ini:ro environment: - GF_INSTALL_PLUGINS=grafana-clock-panel,ryantxu-ajax-panel,volkovlabs-image-panel ``` --- <h2 id="InfluxDB">Docker Compose for InfluxDB</h2> Use the docker image for certbot and add it as a service to Docker Compose project.
🌐
Bogotobogo
bogotobogo.com › DevOps › Docker › Docker_Prometheus_Grafana.php
Docker - Prometheus and Grafana with Docker-compose - 2020
ADMIN_USER=admin ADMIN_PASSWORD=admin docker-compose up -d ... Creating alertmanager ... done Creating pushgateway ... done Creating grafana ... done Creating prometheus ... done Creating nodeexporter ... done Creating caddy ... done Creating cadvisor ...
🌐
TutorialsPoint
tutorialspoint.com › docker › docker_setting_grafana.htm
Docker - Setting Grafana
You have to make some changes in your docker-compose.yaml file to use docker volumes. Replace the existing code with the following code in the docker-compose.yaml file. version: '3' services: grafana: image: grafana/grafana container_name: grafana ports: - "3000:3000" volumes: - ./grafana_data:/var/lib/grafana
🌐
DEV Community
dev.to › ablx › monitoring-setup-with-docker-compose-part-2-grafana-385b
Monitoring setup with docker-compose - Part 2: Grafana - DEV Community
August 24, 2022 - Next, add the following to docker-compose.yml to add Grafana: grafana: image: grafana/grafana:7.5.7 ports: - 3000:3000 restart: unless-stopped volumes: - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources - grafana-data:/var/lib/grafana