Introduction:
Ever faced challenges while trying to run multi-containers with Docker?
I was trying to operationalize my model monitoring and evaluation using Evidently, and had to create a setup to run multi-containers using Docker Compose. I was not expecting a smooth run when I ran
docker-compose --build
in my terminal.
Errors covered are:
- Top-level object must be a mapping
- Additional property volume is not allowed
- Volumes must be a mapping
- * error decoding ‘ports’ : Invalid containerPort: 5432
Top-level object must be a mapping:
If you get this error, "the top-level object must be a mapping" , when you run docker-compose up–build, you need to check your top-level elements, such as name, services, volume, version, e.t.c. Specification of containers are made under applicable top-level elements.
In my case, my top-level elements were all intact. I got to the next bug when I closed the docker-compose.yaml file and executed the docker-compose –build command from the terminal.
Resources:
Stackoverflow: gave me the idea of closing the file and running again
Docker documentation: helped to understand what top level elements are
The Docker forum on the bug: was not useful to me.
Additional property “volumnes” is not allowed
docker-compose.yml: services_grafana Additional property volumnes is not allowed
You will get an error message, similar to the one above if you add an unacceptable term in your configuration. In my case, I got the error because I typed in “volumnes” instead of “volumes” under the grafana container set-up.
I had to read the error carefully to see the mistake.
Resolving this moved me to the next error.
Resources I consulted:
Stackoverflow: Reading the challenges of others helped me to understand what could be the cause of the error, although my challenge was not there.
Docker forum: this was not so helpful
Error: Volumes must be a mapping
.\docker-compose.yml:volumes must be a mapping
This error is due to the wrong indentation of the volume specification (as a top-level element) or a mapping (under a top-level element).
Implementing the right indentations will solve the problem.
Resource
Stackoverflow: The information here was enough
error decoding ‘ports’ : Invalid containerPort: 5432
* error decoding ‘ports’ : Invalid containerPort: 5432
The PostgreSQL database uses port 5432 by default. You must ensure you are using the right port. Inspect your port specifications and indentation, close your yaml file, and run docker-compose-build in your terminal.
docker-compose-build
Reading your codes and understanding the tool you’re working with will reduce the hours you are likely to spend trying to get things to work. Always read documentation to understand the features, and use public forums like stackoverflow.
The docker-compose.yml file
version: '3.7'
volumes:
grafana_data: {}
networks:
front-tier:
back-tier:
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: Bender
ports:
- "5432:5432"
networks:
- back-tier
adminer:
image: adminer
restart: always
ports:
- "8080:8080"
networks:
- back-tier
- front-tier
grafana:
image: grafana/grafana
user: "472"
ports:
- "3000:3000"
volumes:
- ./config/grafana_datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml:ro
networks:
- back-tier
- front-tier
restart: always
Top comments (0)