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/

1047 questions
282
votes
4 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
  • 9,296
  • 9
  • 39
  • 72
194
votes
6 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
  • 5,759
  • 3
  • 23
  • 59
76
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
  • 11,653
  • 14
  • 43
  • 54
67
votes
2 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,142
  • 1
  • 9
  • 20
42
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
  • 2,850
  • 3
  • 24
  • 33
38
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
  • 393
  • 1
  • 3
  • 10
38
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ự
  • 4,962
  • 6
  • 39
  • 81
35
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
  • 9,237
  • 13
  • 60
  • 88
32
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…
29
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
  • 523
  • 1
  • 6
  • 14
28
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
  • 2,446
  • 3
  • 13
  • 28
22
votes
2 answers

docker compose volume type - bind vs volume

TLDR In docker-compose, whats 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
  • 3,729
  • 2
  • 10
  • 28
22
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
  • 1,648
  • 2
  • 13
  • 24
21
votes
3 answers

HostPath with minikube - Kubernetes

UPDATE: I connected to the minikubevm and I see my host directory mounted but there is no files there. Also when I create a file there it will not in my host machine. Any link are between them I try to mount an host directory for developing my app…
20
votes
5 answers

docker-compose volume on node_modules but is empty

I'm pretty new with Docker and i wanted to map the node_modules folder on my computer (for debugging purpose). This is my docker-compose.yml web: build: . ports: - "3000:3000" links: - db environment: PORT: 3000 volumes: -…
Mike Boutin
  • 5,015
  • 11
  • 34
  • 63
1
2 3
69 70