Reputation: 8908
Little disclaimer before I start: I am a Docker newbie.
My question is mostly stated as above, with a little bit more to my requirements:
docker-compose.yml
that I can commit into my source repository and not worry about "how it will run" on multiple platforms. I think what I have below accomplishes that, but I am very open to criticism.docker-compose.yml
:
version: '3.1'
services:
wp:
image: wordpress
restart: always
ports:
- 48080:80
links:
- db:mysql
volumes:
- themes:/var/www/html/wp-content/themes
environment:
WORDPRESS_DB_PASSWORD: example
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
themes:
Any tips for moving forward?
Upvotes: 0
Views: 58
Reputation: 43
The theme volume did not work on my machine. If I run docker-compose up
I get the following error:
This worked for me on Ubuntu 18.04:
version: '3.1'
services:
wp:
image: wordpress
restart: always
ports:
- 48080:80
links:
- db:mysql
volumes:
- ./themes:/var/www/html/wp-content/themes
environment:
WORDPRESS_DB_PASSWORD: example
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
Everything else looks quite good, only improvement for now would be hosting your WordPress on your local file system:
That would give you the possibility to debug WordPress easily and you have full control over the stack.
Downside: User permission can be a problem with Docker. Normally every process inside the container will be executed as root. If WordPress writes a file it has root permissions even on you local file system.
Upvotes: 1