Docker – Portainer with docker-compose and volumes fails

dockerdocker-compose

The Portainer docs are saying:

The -v /opt/portainer:/data option will persist Portainer data in /opt/portainer on the host where Portainer is running. You can specify another location on your filesystem.

I just created the following docker-compose:

portainer:
  image: portainer/portainer
  container_name: portainer
  volumes:
    - /opt/portainer:/data
    - /var/run/docker.sock:/var/run/docker.sock
  ports:
    - 9000:9000

But I don't get a folder /opt/portainer. It seems, that the volume configuration does not work as described in the docs.

Best Answer

docker-compose is expecting the /opt/portainer folder to exist first. Once you create that, you should stop getting the error.

Related Topic