Mounting an External Drive Inside PHP Container

Follow the below steps to mount an external drive inside PHP container to use the Uploads folder.

Steps

  • Create a directory on the host
/data/example.com/uploads/
ADVERTISEMENT
  • Run below command
ee shell example.com
  • Create the directory inside the container where you want to mount the directory
/var/www/htdocs/current/wp-content/uploads
ADVERTISEMENT
  • Edit docker-compose.yml for the site at below location
/opt/easyengine/sites/example.com
  • We need to now add a line like the following at two places.

a. Below the htdocs line for php service

php:
    image: easyengine/php7.3:v4.0.0
    restart: always
    labels:
    - "io.easyengine.site=${VIRTUAL_HOST}"
    volumes:
    - "htdocs:/var/www"
    - "/data/example.com/uploads/:/var/www/htdocs/current/wp-content/uploads"

b. Below the htdocs line for nginx service

nginx:
    image: easyengine/nginx:v4.0.3
    depends_on:
    - php
    restart: always
    labels:
    - "io.easyengine.site=${VIRTUAL_HOST}"
    volumes:
    - "htdocs:/var/www"
    - "/data/example.com/uploads/:/var/www/htdocs/current/wp-content/uploads"
  • Once the above lines are changed Run the below command
ee site disable example.com && ee site enable example.com

Verification

Upload a file and check if you can see the file at the host path. In our example scenario – /data/example.com/uploads/