The default volume driver
Before we start using the third-party volume plugins, we should take a look at what ships with Docker and how volumes solve the scenario we just worked through. Again, we will be using a docker-compose.yml
file; however, this time, we will add a few lines to create and mount volumes:
version: '2' services: wordpress: container_name: my-wordpress-app image: wordpress ports: - "80:80" links: - mysql environment: WORDPRESS_DB_HOST: "mysql:3306" WORDPRESS_DB_PASSWORD: "password" volumes: - "uploads:/var/www/html/wp-content/uploads/" mysql: container_name: my-wordpress-database image: mysql environment: MYSQL_ROOT_PASSWORD: "password" volumes: - "database:/var/lib/mysql" volumes: uploads: driver: local database: driver: local
As you can see, here we are creating two volumes, one called uploads
, which is being mounted to the WordPress uploads folder on the WordPress container...