Reputation: 165
I have run docker-compose up -d
command but volume directories are empty on host.
{
"CreatedAt": "2020-08-29T22:26:49+01:00",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/magento-sandbox_magento_data/_data",
"Name": "magento-sandbox_magento_data",
"Options": null,
"Scope": "local"
}
]
/home/tomas/Documents/Projects/Magento/magento-sandbox
):version: '2'
services:
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=tomas
- MARIADB_PASSWORD=tomas
- MARIADB_DATABASE=magento_sandbox
volumes:
- 'mariadb_data:/home/tomas/Documents/Projects/Magento/magento-sandbox/db'
magento:
image: 'docker.io/bitnami/magento:2-debian-10'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- MAGENTO_DATABASE_USER=tomas
- MAGENTO_DATABASE_PASSWORD=tomas
- MAGENTO_DATABASE_NAME=magento_sandbox
- ELASTICSEARCH_HOST=elasticsearch
- ELASTICSEARCH_PORT_NUMBER=9200
ports:
- '80:80'
- '443:443'
volumes:
- 'magento_data:/home/tomas/Documents/Projects/Magento/magento-sandbox/webroot'
depends_on:
- mariadb
- elasticsearch
elasticsearch:
image: 'docker.io/bitnami/elasticsearch:6-debian-10'
volumes:
- 'elasticsearch_data:/home/tomas/Documents/Projects/Magento/magento-sandbox/elasticsearch/data'
volumes:
elasticsearch_data:
driver: local
mariadb_data:
driver: local
magento_data:
driver: local
Why my /home/tomas/Documents/Projects/Magento/magento-sandbox/webroot is empty? I mean why mountpoint is not reflecting the configuration in the file?
How to achieve the result where this directory contains all the files used to render the page in the browser?
Upvotes: 0
Views: 2051
Reputation: 165
I have managed to find the problem and it turned out to be multiple ones.
I have fixed all of these and it worked. However after all up and running, my elasticsearch failed again but this is another issue and is not related to this one.
Thank you, guys, for your support and effort.
Upvotes: 0
Reputation: 381
Uhm you did create volumes but you did not asign any source paths to them. So they are stored in the default path. (under ubuntu I know it is /var/lib/docker/volumes/HERE). Anyway you will have to find out where the data you want to mount is stored on the docker machines. (you normally set the paths in dockerfiles)
Anyway, the correct syntax is
/path/to/host/machine:/path/in/container/machine
Once you have found that out go ahead and create a .env file in your diretory where your container and compose is stored. It contains
HOST_BASE_DATA_PATH=/home/tomas/Documents/Projects/Magento/magento-sandbox
MAGENTO_DATA_PATH=/insert/the/path/inside/the/magento/container
ELASTICSEARCH_DATA_PATH=/insert/the/path/inside/the/elastic/container
MARIADB_DATA_PATH=/insert/the/path/inside/the/mariadb/container
We will use these variable to get a somehwat cleaner docker-compose file.
In your compose we will specify volumes using the following attributes: ( I hope one example makes it clear enough)
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=tomas
- MARIADB_PASSWORD=tomas
- MARIADB_DATABASE=magento_sandbox
volumes:
- type: bind
# where it will be stored on the host machine
source: ${HOST_BASE_DATA_PATH}/mariadb
# where it is stored on the docker container
target: ${MARIADB_DATA_PATH}
greetings
Upvotes: 2