0

I have a docker volume called influxdb_volume which is physically stored on a mounted external drive (because the docker volume takes up considerable disk space). Previously, this volume was used by a container without problem. However, now I have had to reinstall both the host OS and therefore docker itself, but would now like to reuse this previously created volume.

Is this possible in a simple native docker way (without copying all the data across to a temporary volume using a temporary container) ?


Here is the docker-compose.yaml file:

version: "3"
services:
  influxdb:
    image: influxdb:1.8
    container_name: influxdb_container
    restart: always
    ports:
      - 8086:8086
    networks:
      - docker_monitoring_network
    volumes:
      - influxdb_volume:/var/lib/influxdb
networks:
  docker_monitoring_network:
    external: true
volumes:
  influxdb_volume:
    external: true

and on the previous system I created the docker volume (as described here) using:

docker volume create --driver local \
    --opt type=none \
    --opt device=/mnt/SSD_240GB/docker_data/InfluxDB \
    --opt o=bind influxdb_volume

The issue at the moment is that there are no registered volumes (i.e. running docker volume ls returns nothing.

Ultimately, running docker-compose up gives the following error:

ERROR: Volume influxdb_volume declared as external, but could not be found. Please create the volume manually using `docker volume create --name=influxdb_volume` and try again.

Running another docker volume create as before, and then using the same docker-compose file removes the error, but the data is not appearing in the container. However if I manually run the image (without docker compose) as follows, then it works:

docker run -p 8086:8086 --name influxdb_container -v influxdb_volume:/var/lib/influxdb -d influxdb:1.8

Thank you.

teeeeee
  • 641
  • 5
  • 15
  • if its not working in compose but with docker run, you may have found a bug. Perhaps you should file an issue. – The Fool Jan 24 '23 at 23:04
  • @TheFool do you know if it is required to have the "name:" field in the "volumes" section in the docker-compose.yaml file? – teeeeee Jan 24 '23 at 23:07
  • @TheFool Or whether "--name" needs to be included in the "docker volume create" command? – teeeeee Jan 24 '23 at 23:07
  • Neither is required. The `docker volume create` command does not have a name flag. The name is the first positional argument. – The Fool Jan 24 '23 at 23:12
  • @TheFool Now it is working, don't know why. Sorry to have wasted your time. – teeeeee Jan 25 '23 at 12:49

0 Answers0