-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-compose: no declaration was found in the volumes section #67
Comments
I'm not using compose but am having the same output from
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:
gives
|
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. |
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: If you just want to use the path "data" you have to specify all address of it. Here's an exemple: |
I had the same problem and I just follow the instructions from @jstray adding the
|
I also get the same problem. I am not sure how to debug it, but this is the yml
|
I've tried adding this code below at the end:
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" queue: db: cache: volumes: |
Hey everyone, |
@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 ./ |
Docker has different type of storages. when you give absolute path, it uses docker Bind Mounts while if you specify volume :</where/it/mounts/in/container> in this format, it uses Docker Named volume Storage. https://docs.docker.com/storage/bind-mounts If you want to use named volumes, you must specify it in docker-compose volume section. |
If you want to bind a docker container folder with a host folder (like usual) then use
Here is the official documentation example with static. |
Thank you K-marad, It's worked for me, like.. |
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 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. Docker ComposeNevertheless, 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 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 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 |
your volume declaration should not be one string, try and add at the bottom of your yml file volumes: |
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:
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 :
after :
|
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 |
Thanks so much @enderandpeter |
This solved the issue for me. |
This works for me too |
This is due to
It should be either:
or
or
|
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. They need to be declared (out of the service indentation) at the end of the docker-compose file like that :
|
make sure that volume exist |
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' app: networks: |
Hello.
Trying to spin dvol, but encounter problems:
docker-compose.yml:
spinning docker-compose:
The text was updated successfully, but these errors were encountered: