user7one
(user7)
September 28, 2023, 8:45pm
1
Hi
I have a code line in my .yaml file:
services:
volumes:
- ./data/postgres:/var/lib/postgresql/data
When I attempt to docker compose the file, I get the following error message:
## ERROR: In file ‘./joplin-docker-compose.yaml’, service ‘volumes’ must be a mapping not an array.
I read from another thread that the syntax is wrong:
services:
volumes:
- myVolume: {}
Did not work, however:
services:
volumes:
myVolume: {}
this worked.
When I attempt that syntax with my file:
services:
volumes:
./data/progress:/var/lib/postgresql/data
I get the following error message:
## ERROR: In file ‘./joplin-docker-compose.yaml’, service ‘volumes’ must be a mapping not a string.
I believe my formatting is correct: ‘volumes:’ is indented by four spaces, ‘-./data/postgres:/var/lib/postgresql/data’ is indented by 8 spaces.
I do not know what is wrong with either my syntax or my data. Does anyone have an idea of what the issue is, and can somebody give me a link in the documentation for the compose .yaml file structure and requirements?
rimelek
(Ákos Takács)
September 29, 2023, 5:58pm
2
That could hardly be called “service”. You have to define a service and volumes are defined fo the service.
Assuming this was just a code snippet and you have defined an image as well:
services:
postgres:
volumes:
- ./data/postgres:/var/lib/postgresql/data
# rest of the parameters
user7one
(user7)
September 29, 2023, 8:46pm
3
I have rewritten my compose file:
version: ‘3.0’
services:
db:
image: postgres:latest
volumes:
- todo-postgres-data:/var/lib/postgresql/data
ports:
- “5432:5432”
restart: always
environment:
- POSTGRES_PASSWORD=secret
- POSTGRES_USER=joplin-user
- POSTGRES_DB=joplindb
app:
image: joplin/server:latest
container_name: joplin-server
depends_on:
- db
ports:
- “8080:8080”
restart: always
environment:
- APP_PORT=8080
- APP_BASE_URL=https://localhost
- DB_CLIENT=pg
- POSTGRES_PASSWORD=secret
- POSTGRES_DATABASE=joplindb
- POSTGRES_USER=joplin-user
- POSTGRES_PORT=5432
- POSTGRES_HOST=db
volumes:
todo-postgres-data
However, this fails with a similar error:
parsing joplin-docker-compose.yaml: yaml: line 18: block sequence entries are not allowed in this context
The command I am using to run my compose file is:
docker compose -f joplin-docker-compose.yaml up
rimelek
(Ákos Takács)
September 30, 2023, 6:22am
4
Again, it’s pretty obvious that only the first line was indented under the services.
meyay
(Metin Y.)
September 30, 2023, 7:41am
5
The compose specification is always a good starting point in case something is unclear: https://docs.docker.com/compose/compose-file/