How to properly use named volumes with access

New to Docker and trying to wrap my head around proper management of named volumes.

I’m making a Wordpress stack that uses a Traefik docker container for reverse proxy.

version: '2'

services:
  db:
    image: mysql:5.7
    networks:
      - backend
    volumes:
      - db:/var/lib/mysql
    labels:
      - "traefik.enable=false"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASS}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASS}
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    volumes:
      - wp:/var/www/html
    networks:
      - backend
      - frontend
    restart: always
    labels:
      - "traefik.docker.network=traefik_webgateway"
      - "traefik.frontend.rule=Host:${HOST_NAME}"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: ${DB_USER}
      WORDPRESS_DB_PASSWORD: ${DB_PASS}
      WORDPRESS_DB_NAME: ${DB_NAME}

volumes:
  wp: {}
  db: {}

networks:
  backend:
    driver: bridge
  frontend:
    external:
      name: traefik_webgateway

The named volumes seem encouraged over using bind mounts, so I’m inclined to use them. Also when binding to a local directory I was having issues with mysql not working properly. Having the name is nice too when using docker volume cli.

With this setup everything runs great so far. I may have to add a volume for php upload configs too. My issue is I’m not sure how to properly access and edit the volumes if need be. I know where the mount point is in var/lib though it didn’t seem best practice to just root in and mess around there.

The use case here being if a pluigin update is faulty or incompatible and crashes the site. Now I need to go in and disable the plugins, a simple way is to rename the plugin folder with _ prefixed to the name. Another case may be editing the config or developing a plugin, etc.

Ideally I would like to be able to sftp into named docker volumes, not sure if that’s the best way though. I could create a dockerfile that extend wordpress and setup an sftp on the wordpress container, though I may also have a reason in the future to sftp into the db volume. What is the proper way to edit a named volume mounted in var/lib?

I also will want remote access to the mysql db at some point, using workbench. I could just add it to the frontend and remove the backend and use iptables on host for security, if anyone has a better approach for that feel free to weigh in.

Meh, exactly what I’m looking for :confused:
I’m struggling hard and I’prefer not to bind mount all volumes to allow sftp access.

Leaving tactical dot here : .