I was trying the example provided in the link below for wordpress linking with mysql.
https://www.sitepoint.com/how-to-use-the-official-docker-wordpress-image/
I tried working without the volumes and its working fine. However, when I added volumes in the docker-compose.yml file, it started to give me the following error
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
in "./docker-compose.yml", line 16, column 12
docker-compose.yml file
web:
image: wordpress
links:
- mysql
environment:
- WORDPRESS_DB_PASSWORD=password
ports:
- "127.0.0.3:8080:80"
mysql:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=wordpress
working_dir: /var/www/html
volumes:
- wordpress/wp-content/: /home/tgandhi
Thanks for helping.
The default path for a Compose file is ./docker-compose.yml .
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.
The key difference between docker run versus docker-compose is that docker run is entirely command line based, while docker-compose reads configuration data from a YAML file. The second major difference is that docker run can only start one container at a time, while docker-compose will configure and run multiple.
First of all, working_dir
and volumes
need to go into the web
section of your compose file, not in the mysql
section.
Secondly, the volume mapping is <host path>:<container path>
.
As you specified /var/www/html
as your working dir, the wordpress image uses /var/www/html/wp-content
as the base directory. So you need to mount the directory on your host with static files into /var/www/html/wp-content
. I assuming this to be ~/wordpress
.
web:
image: wordpress
links:
- mysql
environment:
- WORDPRESS_DB_PASSWORD=password
ports:
- "127.0.0.3:8080:80"
working_dir: /var/www/html
volumes:
- /home/tgandhi/wordpress:/var/www/html/wp-content
mysql:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=wordpress
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With