Open Edke opened 8 years ago
I'm not using compose but am having the same output from
# docker volume ls
list dvol: VolumeDriver.List:
<html>
<head><title>404 - No Such Resource</title></head>
<body>
<h1>No Such Resource</h1>
<p>No such child resource.</p>
</body>
</html>
DRIVER VOLUME NAME
local 006b52bbe8e4f33a56ab535fcf56fa2f30bf0668121519071f60b768e45e0b62
local 69f6e1bc35c3421153546c2effcf037f403a6eb44cc0ef10e4ff447fa5235076
local 8b6da2ceda666d70b67d7ae539d7073a6a2dbb4bb43a5d5e211dd54e35fe7b33
local b823b18ed7954b65cf751c6d9a73446750070771006f9d4a33887551bf54182c
It was working fine surviving reboots. The only subsequent docker commands I executed were to init swarm and create an overlay network.
@Edke do you encontered a solution?
@tiagotakahashi sorry no, didnt find solution, not using dvol
Have you try to make relative links (eg. ./)?
Same problem:
version: '3'
services:
web:
image: jonathanstray/cjworkbench
container_name: cjw-web
volumes:
- data:/cjworkbench
ports:
- "8000:8000"
command: /cjworkbench/start-prod.sh
gives
ERROR: Named volume "data:/cjworkbench:rw" is used in service "web" but no declaration was found in the volumes section.
Ah, I see, in both cases above the problem is we have no volumes section in docker-compose.yml, just as the error message suggests: https://docs.docker.com/compose/compose-file/#volume-configuration-reference
ERROR: Named volume "data:/cjworkbench:rw" is used in service "web" but no declaration was found in the volumes section. use ./data instead of data and make sure directory ./data exists.
When you use a named volume, like "data:/cjworkbench:rw" you must declare it at the docker-compose file (at the end as a good pratice). Here's an example:
volumes: data: driver: local
If you just want to use the path "data" you have to specify all address of it. Here's an exemple:
./data:cjworkbench:rw/
I had the same problem and I just follow the instructions from @jstray adding the volumes
section at the end of my docker-compose file.
volumes:
volume-name:
driver: local # is already local by default
I also get the same problem. I am not sure how to debug it, but this is the yml
version: '2'
services:
haproxy:
image: haproxy:1.7
ports:
# stats
- "8036:8036"
# splash
- "8050:8050"
links:
- splash0
- splash1
- splash2
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
splash0:
image: scrapinghub/splash:3.0
command: --max-timeout 3600 --slots 5 --maxrss 3000 --verbosity 1
expose:
- 8050
mem_limit: 4200m
memswap_limit: 5400m
restart: always
links:
- tor
volumes:
- ./proxy-profiles:/etc/splash/proxy-profiles:ro
- ./filters:/etc/splash/filters:ro
splash1:
image: scrapinghub/splash:3.0
command: --max-timeout 3600 --slots 5 --maxrss 3000 --verbosity 1
expose:
- 8050
mem_limit: 4200m
memswap_limit: 5400m
restart: always
links:
- tor
volumes:
- ./proxy-profiles:/etc/splash/proxy-profiles:ro
- ./filters:/etc/splash/filters:ro
splash2:
image: scrapinghub/splash:3.0
command: --max-timeout 3600 --slots 5 --maxrss 3000 --verbosity 1
expose:
- 8050
mem_limit: 4200m
memswap_limit: 5400m
restart: always
links:
- tor
volumes:
- ./proxy-profiles:/etc/splash/proxy-profiles:ro
- ./filters:/etc/splash/filters:ro
tor:
image: jess/tor-proxy
expose:
- 9050
logging:
driver: "none"
restart: always
I've tried adding this code below at the end:
volumes:
filters:
driver: local
proxy-profiles:
driver: local
It doesn't work
Using ./xxxx instead of xxxx solved this issue for me.
I create a volume to my postgres container, but I cant access to it for permission ... Someone can help me?
Hi @Edke ,
You should add volume section in your .yml file, please refer below code:
version: "2" services: web: container_name: web-dev build: context: . dockerfile: services/development/web/Dockerfile links:
cache
queue: container_name: queue-dev image: queue:latest entrypoint: python2.7 manage.py rqworker links:
cache
db: container_name: db-dev image: db:latest volumes:
"db:/var/lib/postgresql/data" volume_driver: dvol
cache: container_name: cache-dev image: redis:latest
volumes: db:
Hey everyone, dvol
is no longer maintained. You might try https://github.com/dotmesh-io/dotmesh instead.
@prat3ik I wonder where you declare the path to "db" ?
Try giving absolute path it resolves for me!
You can use relative path but make sure you prepend ./ So data/video/:/mnt/video/:ro is not working but ./data/video/:/mnt/video/:ro is OKAY.
Docker has different type of storages. when you give absolute path, it uses docker Bind Mounts while if you specify volume
https://docs.docker.com/storage/bind-mounts https://docs.docker.com/storage/volumes
If you want to use named volumes, you must specify it in docker-compose volume section. https://docs.docker.com/compose/compose-file/#volume-configuration-reference
If you want to bind a docker container folder with a host folder (like usual) then use bind
instead of volume
. I give you an example for postgres:
services:
db:
image: postgres
volumes:
- type: bind
source: /host_folder/postgres_data
target: /var/lib/postgresql/data/
Here is the official documentation example with static.
Using ./xxxx instead of xxxx solved this issue for me.
Thank you K-marad, It's worked for me, like.. api → ./api in .yml.
I've tried adding this code below at the end:
volumes: filters: driver: local proxy-profiles: driver: local
It doesn't work
Add it at the top
Hi guys, I have something here that might lead to explanation.
Here is an example I just tried, using only Docker, no docker-compose :
jbl@poste-devops-typique:~/.tungunska/.awx/provision$ docker run -itd --name cerbotiii --restart unless-stopped --entrypoint sh -e path=$tungunska_path -v $data_path:$tungunska_path certbot/certbot
docker: Error response from daemon: create ./data/certbot: "./data/certbot" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.
I here mention the environment :
export data_path=./data/certbot
export tungunska_path=/etc/letsencrypt/live
jbl@poste-devops-typique:~/.tungunska/.awx/provision$ echo "docker run -itd --name cerbotiii --restart unless-stopped --entrypoint sh -e path=$tungunska_path -v $data_path:$tungunska_path certbot/certbot"
docker run -itd --name cerbotiii --restart unless-stopped --entrypoint sh -e path=/etc/letsencrypt/live -v ./data/certbot:/etc/letsencrypt/live certbot/certbot
export domains=(google.io waffle.jp ebay.com) # guess what i was doing
Alright, so, with that docker run
command, I still get the error :
jbl@poste-devops-typique:~/.tungunska/.awx/provision$ docker run -itd --name cerbotiii --restart unless-stopped --entrypoint sh -e path=$tungunska_path -v $data_path:$tungunska_path certbot/certbot
docker: Error response from daemon: create ./data/certbot: "./data/certbot" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.
Now, let's Highlight error message :
"./data/certbot" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
So let's go and use absolute path :
jbl@poste-devops-typique:~/.tungunska/.awx/provision$ docker run -itd --name cerbotiii --restart unless-stopped --entrypoint sh -e path=/etc/letsencrypt/live -v $(pwd)/data/certbot:/etc/letsencrypt/live certbot/certbot
e36e85e0b311b0b434874b6771047d508b37882270d08a8ab79e157425293f07
jbl@poste-devops-typique:~/.tungunska/.awx/provision$
So there you go, it works.
Nevertheless, like many others, I have many times experienced (so wont bother providing example) mapping bind mounted volumes to Docker containers using relative path, but recently exprienced I can't use an env. variable declared for instance in a ./.env
file, and referenced into a docker-compose file.
Well after all, Maybe I will provide an example, some time later.
Thank you all for your remarks, and examples.
I ran into this very issue myself. It is entirely possible to specify a docker volume name, rather than a path, in the short syntax of the volume definition. But if you use a volume name in such a way, you must also specify the name in a top-level volumes:
mapping, so what you want is this:
version: "2"
services:
web:
container_name: web-dev
build:
context: .
dockerfile: services/development/web/Dockerfile
links:
- db
- cache
depends_on:
- db
- cache
queue:
container_name: queue-dev
image: queue:latest
entrypoint: python2.7 manage.py rqworker
links:
- db
- cache
depends_on:
- db
- cache
db:
container_name: db-dev
image: db:latest
volumes:
- "db:/var/lib/postgresql/data"
volume_driver: dvol
cache:
container_name: cache-dev
image: redis:latest
volumes:
db:
Note that last top-level volumes
setting which contains a mapping of a volume name that one of the services
is expected to use.
db: container_name: db-dev image: db:latest volumes:
- "db:/var/lib/postgresql/data" volume_driver: dvol
your volume declaration should not be one string, try db:/var/lib/postgresql/data
and add at the bottom of your yml file
volumes: db:
I came here by chance looking for an answer to another problem. When I was looking for a solution to my problem, I had a similar error.
My ploblem:
FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
HINT: The server must be started by the user that owns the data directory.
If you, like me, have not been helped by the setting of a relative path. Then if you look at the message above and do as you see it in the example, it all worked great. My example before and after:
before :
version: "3"
services:
test_db:
image: postgres:11.5-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: testdb
volumes:
- "./dbdata:/var/lib/postgresql/data"
# the same result if:
# volumes:
# - ./dbdata:/var/lib/postgresql/data
# volumes:
# dbdata:
after :
version: "3"
services:
test_db:
image: postgres:11.5-alpine
ports:
- "5432:5432"
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: testdb
volumes:
- dbdata:/var/lib/postgresql/data/
volumes:
dbdata:
worked for me with absolute path
This thread seems to be of no use, amazed that people say they have a solution but do not give a clear example of what fixed the volume error
Prakash
@pparasuram It looks like the only problem was that the original docker-compose.yml was missing a top-level volumes
key that named the volume to be used in the shorthand syntax db:/var/lib/postgresql/data
. With such a setting, the db
volume name needs to be listed as a key under volumes:
. It has also been suggested that removing the quotes around that string might help.
@pparasuram It looks like the only problem was that the original docker-compose.yml was missing a top-level
volumes
key that named the volume to be used in the shorthand syntaxdb:/var/lib/postgresql/data
. With such a setting, thedb
volume name needs to be listed as a key undervolumes:
. It has also been suggested that removing the quotes around that string might help.
Thanks so much @enderandpeter
Using ./xxxx instead of xxxx solved this issue for me.
This solved the issue for me.
Using ./xxxx instead of xxxx solved this issue for me.
This works for me too
This is due to
container:
volumes:
<object>:<target>
It should be either:
container:
volumes:
./<object>:<target>
or
container:
volumes:
/full/path/to/<object>:<target>
or
container:
volumes:
<name>:<target>
volumes:
name:
driver: local
If you want to use named volumes you should follow this one: https://docs.docker.com/storage/volumes/#use-a-volume-with-docker-compose
Named volumes can be used by multiple services. If u need to name it using for ex : mongo-data:db/data
They need to be declared (out of the service indentation) at the end of the docker-compose file like that :
node-app-data:
image: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=usr
- MONGO_INITDB_ROOT_PASSWORD=psswd
volumes:
- mongo-db:/data/db
volumes:
mongo-db:
make sure that volume exist
ERROR: Named volume "data:/cjworkbench:rw" is used in service "web" but no declaration was found in the volumes section. use ./data instead of data and make sure directory ./data exists.
Example with SQLServer
version: '3'
services:
server:
container_name: "${LOCALSTACK_DOCKER_NAME}-server"
image: mcr.microsoft.com/mssql/server:2017-CU31-ubuntu-18.04
ports:
- 1433:1433
environment:
- ACCEPT_EULA="Y"
- MSSQL_SA_PASSWORD=A12345!ab
volumes:
- "./data/yardi-mssql/data:/var/opt/mssql/data"
- "./data/yardi-mssql/log:/var/opt/mssql/log"
- "./data/yardi-mssql/secrets:/var/opt/mssql/secrets"
volumes:
data:
The folder `data' must exist within the same level
I had same error but i was able to solve it following instructions from this thread. This is how my compose yml looks like now
version: '3.1' services: dbpostgresql: image: "postgres:12" container_name: dbpostgresql networks:
db:/var/lib/postgresql/data environment: POSTGRES_DB: loll POSTGRES_PASSWORD: loll
app: container_name: e-l image: e-l networks:
networks: el-pgsql: volumes: db:
Hello.
Trying to spin dvol, but encounter problems:
docker-compose.yml:
spinning docker-compose: