service "redis" refers to undefined volume abcdrf: invalid compose project - docker-compose

This is just an example docker-compose file, where I am trying to create a container out of it. The problem I am getting while building a container is the below error
"service "redis" refers to undefined volume abcdrf/: invalid compose project"
Please can anyone help me what is wrong happening in this case.
Below is my example docker-compose file code...
version: '2'
services:
redis:
image: redis:2
volumes:
- abcdrf/:/.
command: "redis-server --notify-keyspace-events Ex"
volumes:
abcdrf:

Related

RabbitMQ - How to use custom configuration file in docker-compose?

I'm a beginner in using rabbitmq and docker-compose.
I cannot figure out how to use my own config file... At start, rabbitmq service keeps exiting with the error:
rabbitmq1 | 2022-06-17 14:50:43.578486+00:00 [error] <0.130.0> Failed to load advanced configuration file "/etc/rabbitmq/rabbitmq.config": 1: syntax error before:
My conf file is the following one (myrabbit.conf)
consumer_timeout = 10000
The file is in the same directory then the docker-compose file which is:
version: "3"
services:
rabbitmq:
image: rabbitmq:3-management
container_name: rabbitmq1
hostname: 'rabbitmq'
ports:
- "5672:5672"
- "15672:15672"
volumes:
- ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/mnesia/
- ./myrabbit.conf:/etc/rabbitmq/rabbitmq.config #problematic line I guess...
restart: always
Other test:
Instead of this :
- ./myrabbit.conf:/etc/rabbitmq/rabbitmq.config
When I try this:
- myrabbit.conf:/etc/rabbitmq/rabbitmq.config
I get the following error:
ERROR: Named volume "myrabbit.conf:/etc/rabbitmq/rabbitmq.config:rw" is used in service "rabbitmq" but no declaration was found in the volumes section.
I finally made it works.
Here is what I did:
Create a directory called "rabbitmq" in the same directory than the docker-compose.yml file
In that new directory, create the file: rabbitmq.conf (to be confirmed, but it appears that it must be that name).
Adapt the docker-compose.yml file as following:
version: "3"
services:
rabbitmq:
image: rabbitmq:3-management
container_name: rabbitmq
hostname: 'rabbitmq'
ports:
- "5672:5672"
- "15672:15672"
volumes:
- ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/mnesia/
- ./rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
restart: always
During the boot, you should see:
Which means that rabbitmq service is well using the custom conf file.
Hope it will help others...

volume mongodb with docker-compose

I try to turn docker-compose with volume mongodb; But Iget this error and I don't know the origin of this error any idea:
ERROR: for api_db_1 Cannot start service db: OCI runtime create failed: invalid mount {Destination:mongo-data Type:bind Source:/var/lib/docker/volumes/110cc05fb16f8f6381dea1ff6d17e95e4f8458d98e87e9524514653b19db8e6d/_data Options:[rbind]}: mount destination mongo-data not absolute: unknown
I use image mongo:3.6-xenial for mongo and docker-compose version 1.29.2.
I ended up with the same error.
My problem was that I didn't specify the file path in which the volume was set in.
I believe for your case, you have a service called db that uses volumes called mongo-data.
Something like below...
services:
db:
// other service specifications
volumes:
- mongo-data
What I did to solve was to specify the file path docker can look for, similar to this...
services:
db:
// other service specifications
volumes:
- mongo-data:mongo-data-file-path
I'm with the same error here :-(
ERROR: for firebird_db_1 Cannot start service db: failed to create shim: OCI runtime create failed: invalid mount {Destination:storage Type:bind Source:/var/lib/docker/volumes/7d63ff4c2624358a5278b14e08e911077dae3359709bd5e114b25591dbf6e1a0/_data Options:[rbind]}: mount destination storage not absolute: unknown
my docker-compose file is this:
PS.: this docker-compose file was working until a few weeks ago...
version: "3.2"
services:
db:
image: jacobalberty/firebird
volumes:
- ./storage
restart: on-failure
environment:
TZ: America/Sao_Paulo
ISC_PASSWORD: masterkey
FIREBIRD_DATABASE: dev
FIREBIRD_USER: dev
FIREBIRD_PASSWORD: dev
EnableLegacyClientAuth: 'true'
ports:
- 3050:3050
Assign an absolute path for volume mongo-data in docker-compose file should work.

ERROR: Named volume "mongodb:/data/db:rw" is used in service "mongo" but no declaration was found in the volumes section

I just start learning Docker recently. Trying to set up a service that stores database.
Here's my docker-compose.yml:
version: "3.7"
services:
mongo:
image: mongo
ports:
- 27018:27017
volumes:
- mongodb:/data/db
volumes:
mongo:
As I run docker-compose up ., I got this error:
ERROR: Named volume "mongodb:/data/db:rw" is used in service "mongo" but no declaration was found in the volumes section.
And I did create my named volume mongodb outside. Running docker volume ls would give me:
DRIVER VOLUME NAME
local mongodb
Any ideas? Thanks alot.
For named volumes you should have a "volumes" key on a same level as "services", and any named volumes you are using in your services have to be listed under the "volumes" key (where you missed).
in your case :
version: "3.7"
services:
mongo:
image: mongo
ports:
- 27018:27017
volumes:
- mongodb:/data/db
volumes:
mongodb:
Just a reminder : anonymous volumes, and bind mounts don't need to be specified here.
hope this helped you :)

Docker-Compose MariaDB creates my volume but still uses container id volume

I can't seem to get docker/Maria to use my named docker volume. The host docker volumes directory is empty. But, there is a new container id right next to my named volume that looks like it has all of the MariaDB parts in it. The question is why?
My docker compose file:
version: "3.7"
#
# [Volumes]
#
volumes:
data-mysql:
#
# [Services]
#
services:
mariadb:
volumes:
- data-mysql:/var/lib/mysql
image: linuxserver/mariadb
container_name: mariadb
environment:
- PUID=1000
- GUID=1000
- MYSQL_ROOT_PASSWORD=<snipped>
- TZ=Etc/UTC
ports:
- 3306:3306
restart: unless-stopped
I've tried moving the volume part before and after the services line with no difference. When I do a docker-compose up, it does say it's creating the volume: mariadb_data-mysql, but when I shut down docker, there is nothing in the folder.
Thanks for any insight!
Nick
The data folder for MARIADB image you are using (linuxserver/mariadb) is /config/databases/ and not /var/lib/mysql. Replace this in your docker-compose.yml and it will work.
Also, the order in your docker-compose.yml does not matter: docker-compose will compile it and order everything alphabetically anyway before processing.

Docker-compose postgresql integration

I'm new to docker and am trying to make a composed image consisting of services, nginx and postgresql database. I'm following the tutorial here : http://www.patricksoftwareblog.com/how-to-use-docker-and-docker-compose-to-create-a-flask-application/
And have been successful up to adding postgresql where I'm having difficulties and questions.
My docker-compose.yml:
version : '2'
services:
web:
restart: always
build: ./home/admin/
expose:
- "8000"
nginx:
restart: always
build: ./etc/nginx
ports:
- "80:80"
volumes:
- /www/static
volumes_from:
- web
depends_on:
- web
data:
image: postgres:9.6
volumes:
- /var/lib/postgresql
command: "true"
postgres:
restart: always
build: ./var/lib/postgresql
volumes_from:
- data
ports:
- "5432:5432"
I have included his docker generator script under /var/lib/postgresql but keep facing ERROR: Dockerfile parse error line 1: unknown instruction: IMPORT when I run 'docker-compose build'.
If I leave in the 'data' section & remove the postgres section in my docker-compose.yml file, my containers seemingly run fine but I'm unsure if postgresql is properly running at all. I'm able to GET using curl but still - I'm unsure how to go about confirming postgres specifics to confirm a proper environment and would appreciate examples on this topic in particular.
I was also wondering if running my docker-compose containers then simply running a separate postgresql container could also function if provided the correct ports.
Thank you!
Check the content of your docker-compose.yml:
yaml format (see for instance codebeautify.org/yaml-validator)
eol or encoding issue
multi-line instructions