Tushar Gandhi
Tushar Gandhi

Reputation: 247

issue with the docker compose file

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.

Upvotes: 7

Views: 4042

Answers (1)

Martin
Martin

Reputation: 3114

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

Upvotes: 15

Related Questions