Docker Community Forums

Share and learn in the Docker community.

[NOOB] How to link a Docker Volume to a Local Drive

Hi, Apologies for what is probably a basic question, but i’m so new to this that i can’t find an answer to my question. I have tried searching but nothing i have tried works… probably means that it is a syntax thing that i’m not understanding.

Anyways, I’m trying to create a wordpress image so that i can develop a site, and then port it once complete.

I want to link the root file that contains the compose file, to hold all the files from the apache server (one video said it was /var/www/html. I think that this is right.

If you need more information to help diagnose, please let me know what commands to run to get the info and i’ll post.

Here is the compose file (pardon the indenting… wasn’t sure how to copy it correctly):

version: '3.3'

services:
 db:
    image: mysql:5.7
    volumes:
     - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    networks:
     - wpnetwork

wordpress:
 depends_on:
  - db
 image: wordpress:latest
 ports:
  - "8000:80"
 restart: always
 volumes:
  - ./:/var/www/html
 environment:
  WORDPRESS_DB_HOST: db:3306
  WORDPRESS_DB_USER: wordpress
  WORDPRESS_DB_PASSWORD: wordpress
  WORDPRESS_DB_NAME: wordpress
 networks:
  - wpnetwork

volumes:
  db_data:
networks:
  wpnetwork: