I'm posting this question here in the hope that I'm just using Docker wrong and someone can explain how to fix it. I don't think the problem is with the headless-wp-starter GitHub project itself, but in case it is I will ask about it somewhere else.
Currently I'm trying to install this to develop locally on Ubuntu 18.10. Here's my installation process. I made sure to delete volumes/images/containers, etc. from my last Docker installation and start from scratch.
I'm trying to install headless-wp-starter, start by installing
dockerandcomposersudo apt install composer docker`Installing docker-compose separately as explained in the Docker Docs here.
Testing docker-compose to see if everything works.
docker-compose --version docker-compose version 1.24.0, build 0aa59064Move contents of git into a whole new folder located at
/opt/lampp/htdocs/headless-wp.cd /opt/lampp/htdocs/headless-wp sudo docker-compose up -dI need sudo because I get:
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running? If it's at a nonstandard location, specify the URL with the DOCKER_HOST environment variable.Everything works fine until the end where I get:
Creating db-headless ... done Creating frontend-graphql ... done Creating frontend ... done Creating wp-headless ... error ERROR: for wp-headless Cannot start service wp-headless: OCI runtime create failed: container_linux.go:344: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown ERROR: for wp-headless Cannot start service wp-headless: OCI runtime create failed: container_linux.go:344: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown ERROR: Encountered errors while bringing up the project.
I'm not familiar with Docker at all. I've googled this, but I haven't been able to find a solution.
I've been able to get wp-headless to run by changing this part of
docker-compose.yml:
wp-headless:
build: .
command: bash -c 'install_wordpress && apache2-foreground'
container_name: wp-headless
depends_on:
- db-headless
env_file: ./.env
ports:
- '8080:8080'
user: www-data
volumes:
- ./wordpress:/var/www/html
- ./docker/install_wordpress.sh:/usr/local/bin/install_wordpress
- ./docker/migratedb_import.sh:/usr/local/bin/migratedb_import
- ./docker/postlightheadlesswpstarter.wordpress.xml:/var/www/postlightheadlesswpstarter.wordpress.xml
- ./docker/plugins:/var/www/plugins
to
wp-headless:
build: .
command: bash -c 'install_wordpress && apache2-foreground'
container_name: wp-headless
depends_on:
- db-headless
env_file: ./.env
ports:
- '8080:8080'
user: www-data
volumes:
- ./wordpress:/opt/lampp/htdocs/headless-wp
- ./docker/install_wordpress.sh:/usr/local/bin/install_wordpress
- ./docker/migratedb_import.sh:/usr/local/bin/migratedb_import
- ./docker/postlightheadlesswpstarter.wordpress.xml:/var/www/postlightheadlesswpstarter.wordpress.xml
- ./docker/plugins:/var/www/plugins
Even if WordPress is running, there is no JSON output, so the front-end doesn't work.
Edit: I tried installing Docker by following this post. I also tried extracting git to /var/www/html but I still get the same error:
/var/www/html/headless-wp-starter-master$ sudo docker-compose up -d
db-headless is up-to-date
frontend-graphql is up-to-date
frontend is up-to-date
Starting wp-headless ... error
ERROR: for wp-headless
Cannot start service wp-headless: OCI runtime create failed:
container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown
ERROR: for wp-headless
Cannot start service wp-headless: OCI runtime create failed:
container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown
ERROR: Encountered errors while bringing up the project.
Link to the full installation log
Questions:
Does this installation seem correct or have I made a mistake somewhere?
Should I move headless-wp-starter which was downloaded from GitHub to a different folder predetermined by Docker?
Am I installing the right version of Docker? There seem to be a lot of versions, and that's also causing confusion.