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...
Related
Blessings,
I've got a docker-compose.yml and I am trying to push it to Azure container registry but it skips the upload.
# docker-compose.yml
version: '3'
services:
proxy:
image: nginx:1.17.3
ports:
- 80:80
- 443:443
volumes:
# Mount the nginx folder with the configuration
- ./nginx:/etc/nginx:ro
# Mount the letsencrypt certificates
- /etc/letsencrypt:/etc/letsencrypt:ro
fdp:
image: fairdata/fairdatapoint:1.15
volumes:
- ./application.yml:/fdp/application.yml:ro
fdp-client:
image: fairdata/fairdatapoint-client:1.15
environment:
- FDP_HOST=fdp
mongo:
image: mongo:4.0.12
ports:
- "127.0.0.1:27017:27017"
volumes:
- ./mongo/data:/data/db
blazegraph:
image: metaphacts/blazegraph-basic:2.2.0-20160908.003514-6
volumes:
- ./blazegraph:/blazegraph-data
I know the above has to be edited according to this documentation
But I couldn't quite understand how the changes should be applied and would need some guidance.
I've tried building successfully using docker-compose up --build -d then docker-compose push returns the the following
[+] Running 5/0
- blazegraph Skipped 0.0s
- proxy Skipped 0.0s
- fdp Skipped 0.0s
- fdp-client Skipped 0.0s
- mongo Skipped
I've had to add a dockerfile and change the following inside my docker-compose
app:
build: .
image: foo.azurecr.io/foo
container_name: foo
Prefix should be used when trying to push to ACR.
Dockerfile was just a simple python application installing dependencies, It is required to push so It was kept basic.
This is my first time using environment variables in docker-compose.
When I run the docker-compose up command I get the error:
docker-compose Couldn't find env file: ${path}\variables.env
Hereinafter "path" is the path to the project in Windows.
Here is my docker-compose.yml:
version: '3.1'
services:
geo:
build:
context: .
image:geo_image
container_name: geo
ports:
- "3003:3003"
volumes:
- ${path}:/var/geo/data
- /app/node_modules
- ${path}:/app
env_file: variables.env
networks:
default:
external:
name: geonw
The variables.env file is located at the root of the project.
Without variables.env everything works fine.
Tell me, please, what is the error?
I tried giving the full path to the file, but that didn't work either.
I also carefully checked the correct name of the file variables.env, there is no error there.
I'm sorry, but it was just my stupid mistake and inattention. I created a variables.env file at a level higher than the directory with the docker-compose.yml file.
2 hours wasted...
Answer: The variables.env and docker-compose.yml files must be in the same directory.
Try this should work.. also try with \ slash .\variables.env
version: '3.1'
services:
geo:
build:
context: .
image:geo_image
container_name: geo
ports:
- "3003:3003"
volumes:
- ${path}:/var/geo/data
- /app/node_modules
- ${path}:/app
env_file:
- ./variables.env
networks:
default:
external:
name: geonw
Currently I have setup my service like the following.
version: '3'
services:
gateway:
container_name: gateway
image: node:lts-alpine
working_dir: /
volumes:
- ./package.json:/package.json
- ./tsconfig.json:/tsconfig.json
- ./services/gateway:/services/gateway
- ./packages:/packages
- ./node_modules:/node_modules
env_file: .env
command: yarn run ts-node-dev services/gateway --colors
ports:
- 3000:3000
So I have specified one env_file. But now I want to pass multiple .env files.
Unfortunately, the following is not possible:
env_files:
- .env.secrets
- .env.development
Is there any way to pass multiple .env files to one service in docker-compsoe?
You can specify multiple env files on the env_file option (without s).
For instance:
version: '3'
services:
hello:
image: alpine
entrypoint: ["sh"]
command: ["-c", "env"]
env_file:
- a.env
- b.env
Note that, complementary to #conradkleineespel's answer, if an environment variable is defined in multiple .env files listed under env_file, the value found in the last environment file in the list overwrites all prior (tested in a docker-compose file with version: '3.7'.
Here is a part of my project structure:
Here is a part of my docker-compose.yml file:
Here is my Dockerfile (which is inside postgres-passport folder):
I have init.sql script which should create user, database and tables (user and db are the same as in docker-compose.yml file)
But when I look into my docker-entrypoint-initdb.d folder it is empty (there is no init.sql file). I use this command:
docker exec latest_postgres-passport_1 ls -l
docker-entrypoint-initdb.d/
On my server (Ubuntu) I see:
I need your help, what am I doing wrong? (how can I copy a folder with init.sql script. Postgres tell me that
/usr/local/bin/docker-entrypoint.sh: ignoring
/docker-entrypoint-initdb.d/*
(as he can't find this folder)
All code in text format below:
Full docker-compose.yml:
version: '3'
volumes:
redis_data: {}
proxy_certs: {}
nsq_data: {}
postgres_passport_data: {}
storage_data: {}
services:
# ####################################################################################################################
# Http services
# ####################################################################################################################
back-passport:
image: ${REGISTRY_BASE_URL}/backend:${TAG}
restart: always
expose:
- 9000
depends_on:
- postgres-passport
- redis
- nsq
environment:
ACCESS_LOG: ${ACCESS_LOG}
AFTER_CONFIRM_BASE_URL: ${AFTER_CONFIRM_BASE_URL}
CONFIRM_BASE_URL: ${CONFIRM_BASE_URL}
COOKIE_DOMAIN: ${COOKIE_DOMAIN}
COOKIE_SECURE: ${COOKIE_SECURE}
DEBUG: ${DEBUG}
POSTGRES_URL: ${POSTGRES_URL_PASSPORT}
NSQ_ADDR: ${NSQ_ADDR}
REDIS_URL: ${REDIS_URL}
SIGNING_KEY: ${SIGNING_KEY}
command: "passport"
# ####################################################################################################################
# Background services
# ####################################################################################################################
back-email:
image: ${REGISTRY_BASE_URL}/backend:${TAG}
restart: always
depends_on:
- nsqlookup
environment:
DEFAULT_FROM: ${EMAIL_DEFAULT_FROM}
NSQLOOKUP_ADDR: ${NSQLOOKUP_ADDR}
MAILGUN_DOMAIN: ${MAILGUN_DOMAIN}
MAILGUN_API_KEY: ${MAILGUN_API_KEY}
TEMPLATES_DIR: "/var/templates/email"
command: "email"
# ####################################################################################################################
# Frontend apps
# ####################################################################################################################
front-passport:
image: ${REGISTRY_BASE_URL}/frontend-passport:${TAG}
restart: always
expose:
- 80
# ####################################################################################################################
# Reverse proxy
# ####################################################################################################################
proxy:
image: ${REGISTRY_BASE_URL}/proxy:${TAG}
restart: always
ports:
- 80:80
- 443:443
volumes:
- "proxy_certs:/root/.caddy"
environment:
CLOUDFLARE_EMAIL: ${CLOUDFLARE_EMAIL}
CLOUDFLARE_API_KEY: ${CLOUDFLARE_API_KEY}
# ACME_AGREE: 'true'
# ####################################################################################################################
# Services (database, event bus etc)
# ####################################################################################################################
postgres-passport:
image: postgres:latest
restart: always
expose:
- 5432
volumes:
- "./postgres-passport:/docker-entrypoint-initdb.d"
- "./data/postgres_passport_data:/var/lib/postgresql/data"
environment:
POSTGRES_DB: ${POSTGRES_PASSPORT_DB}
POSTGRES_USER: ${POSTGRES_PASSPORT_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSPORT_PASSWORD}
redis:
image: redis
restart: always
expose:
- 6379
volumes:
- "redis_data:/data"
nsqlookup:
image: nsqio/nsq:v1.1.0
restart: always
expose:
- 4160
- 4161
command: /nsqlookupd
nsq:
image: nsqio/nsq:v1.1.0
restart: always
depends_on:
- nsqlookup
expose:
- 4150
- 4151
volumes:
- "nsq_data:/data"
command: /nsqd --lookupd-tcp-address=nsqlookup:4160 --data-path=/data
# ####################################################################################################################
# Ofelia cron job scheduler for docker
# ####################################################################################################################
scheduler:
image: mcuadros/ofelia
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./etc/scheduler:/etc/ofelia"
Dockerfile:
FROM postgres:latest
COPY init.sql /docker-entrypoint-initdb.d/
In your docker-compose.yml file, you say in part:
postgres-passport:
image: postgres:latest
volumes:
- "./postgres-passport:/docker-entrypoint-initdb.d"
- "./data/postgres_passport_data:/var/lib/postgresql/data"
So you're running the stock postgres image (the Dockerfile you show never gets called); and whatever's in your local postgres-passport directory, starting from the same directory as the docker-compose.yml file, appears as the /docker-entrypoint-initdb.d directory inside the container.
In the directory tree you show, if you
cd deploy/latest
docker-compose up
The ./postgres-passport is expected to be in the deploy/latest tree. Since it's not actually there, Docker doesn't complain, but just creates it as an empty directory.
If you're just trying to inject this configuration file, using a volume is a reasonable way to do it; you don't need the Dockerfile. However, you need to give the correct path to the directory you're trying to mount into the container.
postgres-passport:
image: postgres:latest
volumes:
# vvv Change this path vvv
- "../../postgres-passport/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d"
- "./data/postgres_passport_data:/var/lib/postgresql/data"
If you want to use that Dockerfile instead, you need to tell Docker Compose to build the custom image instead of using the standard one. Since you're building the init file into the image, you don't also need a bind-mount of the same file.
postgres-passport:
build: ../../postgres-passport
volumes:
# Only this one
- "./data/postgres_passport_data:/var/lib/postgresql/data"
(You will also need to adjust the COPY statement to match the path layout; just copying the entire local docker-entrypoint-initdb.d directory into the image is probably the most straightforward thing.)
I am trying to learn how to utilize docker-compose and was following instructions until I received an error. Here's my docker-compose file.
version: '3.7'
services:
web:
build: ./app
command: python /usr/src/app/manage.py runserver 0.0.0.0:8000
volumes:
- ./app/:/usr/src/app/
ports:
- 8000:8000
environment:
- SECRET_KEY=my_secret_key
- SQL_ENGINE=django.db.backends.postgresql
- SQL_DATABASE=postgres
- SQL_USER=postgres
- SQL_PASSWORD=postgres
- SQL_HOST=db
- SQL_PORT=5432
depends_on:
- db
db:
images: postgres:10.7-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
volumes:
postgres_data:
When I go back and enter "docker-compose up -d --build", I would get an error saying
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.db: 'images'
I think I have the indentation correct and 'images' look okay to me.
My docker-compose version is 1.23.2 and trying to run this on Mac.
Any ideas? thanks in advance.
It should be image not images.