Questions tagged [docker-volume]

A docker data volume is a specially-designated directory within one or more containers that bypasses the Union File System.

A docker data volume is a specially-designated directory within one or more containers that bypasses the Union File System. Data volumes provide several useful features for persistent or shared data:

  • Volumes are initialized when a container is created. If the container’s base image contains data at the specified mount point, that existing data is copied into the new volume upon volume initialization.
  • Data volumes can be shared and reused among containers.
  • Changes to a data volume are made directly.
  • Changes to a data volume will not be included when you update an image.
  • Data volumes persist even if the container itself is deleted.

Reference: https://docs.docker.com/engine/userguide/dockervolumes/

1402 questions
384
votes
5 answers

How to persist data in a dockerized postgres database using volumes

My docker compose file has three containers, web, nginx, and postgres. Postgres looks like this: postgres: container_name: postgres restart: always image: postgres:latest volumes: - ./database:/var/lib/postgresql ports: -…
Alex Lenail
  • 12,992
  • 10
  • 47
  • 79
369
votes
8 answers

How do I mount a host directory as a volume in docker compose

I have a development environment I'm dockerizing and I would like the ability to livereload my changes without having to rebuild docker images. I'm using docker compose because redis is one of my app's dependencies and I like being able to link a…
Amin Shah Gilani
  • 8,675
  • 5
  • 37
  • 79
152
votes
2 answers

How to set a path on host for a named volume in docker-compose.yml

Example below creates dbdata named volume and references it inside db service: version: '2' services: db: image: mysql volumes: - dbdata:/var/lib/mysql volumes: dbdata: driver: local (from…
misha
  • 1,521
  • 2
  • 10
  • 5
138
votes
4 answers

How to determine what containers use the docker volume?

Suppose I have a volume and I know its name or id. I want to determine the list of containers (their names or ids) that use the volume. What commands can I use to retrieve this information? I thought it can be stored in the output of docker volume…
gerichhome
  • 1,872
  • 2
  • 15
  • 21
100
votes
5 answers

Docker-compose named mounted volume

In order to keep track of the volumes used by docker-compose, I'd like to use named volumes. This works great for 'normal' volumes like version: 2 services: example-app: volume: -named_vol:/dir/in/container/volume volumes: …
pvgoddijn
  • 12,638
  • 15
  • 47
  • 56
66
votes
3 answers

ERROR: Named volume "xplore:/root/xPlore/rtdata:rw" is used in service "dsearch" but no declaration was found in the volumes section

I wanted to create containers for tomcat, documentum content server and documentum xplore by using a single compose file. Am facing issues due to the volumes mentioned in the docker-compose.yml file. Am able to bring up the services by executing the…
64
votes
4 answers

How to change the default location for "docker create volume" command?

When creating volumes through the volume API, that is, as the container volume pattern is now not necessarily the best practice anymore: # docker volume inspect test-data [ { "Name": "test-data", "Driver": "local", …
dukeofgaming
  • 3,108
  • 4
  • 28
  • 35
56
votes
4 answers

docker-compose: define mount for bind mount and managed mount

I'm using docker-compose for defining my service. In docker, there are two concepts for docker volume. Firstly is about bind mount: mount on host storage. docker run -d --name web-app -v $HOST/location:/container/location -p 80:80…
Trần Kim Dự
  • 5,872
  • 12
  • 55
  • 107
53
votes
2 answers

Unsupported config option for services.volumes

Trying to setup docker for the first time and I'm running into a problem with volumes. I feel pretty confident that the spacing and formatting in the .yml is correct at this point. I've tried versions 3, 3.1, 3.2, 3.3 and 3.4. All are getting the…
Coy
  • 543
  • 1
  • 4
  • 10
43
votes
3 answers

docker volume type - bind vs volume

TLDR In docker-compose, what's the difference between volumes: - type: volume source: mydata target: /data and volumes: - type: bind source: mydata target: /data ? The question in long: When you specify the volumes…
Efrat Levitan
  • 5,181
  • 2
  • 19
  • 40
43
votes
3 answers

Add bind mount to Dockerfile just like volume

I want to add the bind mount to docker file just like I initialise a volume inside Dockefile. Is there any way for it?
Mufeed
  • 3,018
  • 4
  • 20
  • 29
43
votes
2 answers

Docker Compose Relative paths vs Docker volume

I have a docker compose file for a website, which amongst a bunch of other containers for various purposes, includes a mysql database that will have persistent data. At the moment the compose file specifies a relative path for the data, e.g.: …
statts
  • 435
  • 1
  • 4
  • 4
43
votes
1 answer

Understanding docker -v command

I was just going through this tutorial on Youtube, trying to understand the use of the -v command. Why is the author using the -v command? He uses the command, like so: docker run -v /var/lib/mysql --name=my_datastore -d busybox echo "my…
Tenali_raman
  • 2,000
  • 3
  • 18
  • 28
41
votes
3 answers

Mount a volume in docker-compose conditionally

I have a docker-compose.yml configuration. In one of the containers there is a Tomcat server and it has some default .war file deployed in webapps directory. I want to have an ability to pass (override) the war archive to be deployed by some which…
fxmasa
  • 714
  • 1
  • 8
  • 14
41
votes
9 answers

ERROR: In file './docker-compose.yml', volume must be a mapping not a string

Question: Why do I get this error? ERROR: In file './docker-compose.yml', volume 'mariavolume' must be a mapping not a string. My docker-compose file is almost identical to this one: https://docs.docker.com/compose/wordpress/ version:…
Richard
  • 14,798
  • 21
  • 70
  • 103
1
2 3
93 94