Return to

Docker volumes mappings and docker-compose


I’m attempting to secure an Ubuntu 18.04 server for use with Traefik, Nextcloud and Let’s encrypt. I’ve decided to learn Docker to accomplish these things. With no practical experience, I’m turning to guides written by generous people online.

Anyway, I’m attempting to follow the “Setting up a VPS to self-host with Docker” in the How-To section of this site. I’ve followed the guide up until running docker-compose up -d to get Traefik running. Docker tells me “ERROR: In file ‘./docker-compose.yml’, service ‘volumes’ must be a mapping not an array.” Googling the error results in suggestions that the formatting may be incorrect. Here is the guide I’m attempting to use.

And here is the file specifically:


version: "3"

   container_name: traefik
   image: traefik:alpine
     - 80:80
     - 443:443
     - 8080:8080
   restart: unless_stopped
     - ./selfhosted/traefik:/etc/traefik
     - /var/run/docker.sock:/var/run/docker.sock

Docker version: 19.03.8
Docker-compose version 1.17.1

If anyone can offer me some helpful advice, I’d appreciate it.

Post your file Your file format seems consistent with Message #1 in that thread. But it looks a little odd to me (not an expert, just a dabbler).

Message #12 in that thread, by blackandred, shows a little different syntax for the same file. Perhaps the indentation of “traefik:” as shown in #12 might be helpful?

1 Like

Thank you for pointing that out. I indented every line by three spaces and ‘docker-compose up -d’ succeeded without an error.