version: '3.6' services: db: image: mysql:5.7 volumes: - ~/wordpress/database:/var/lib/mysql restart: always env_file: ".env" environment: MYSQL_ROOT_PASSWORD: $(MYSQL_ROOT_PASSWORD) MYSQL_DATABASE: $(MYSQL_DATABASE) MYSQL_USER: $(MYSQL_USER) MYSQL_PASSWORD: $(MYSQL_PASSWORD) wordpress: image: wordpress:latest depends_on: - db ports: - 8080:80 # change to 80:80 when the shop is ready to go live restart: always env_file: ".env" environment: WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME} WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST} WORDPRESS_DB_USER: ${WORDPRESS_DB_USER} WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD} volumes: - ~/wordpress/data:/var/www/html wordpress-cli: depends_on: - db - wordpress image: wordpress:cli # vstm: This is required to run wordpress-cli with the same # user-id as wordpress. This way there are no permission problems # when running the cli user: '33' # vstm: The sleep 10 is required so that the command is run after # mysql is initialized. Depending on your machine this might take # longer or it can go faster. ## command: > ## /bin/sh -c ' ## sleep 10; ## wp core install --path="/var/www/html" --url="http://localhost:8080" --title="Local Wordpress By Docker" --admin_user=admin --admin_password=supersecretpassword --admin_email=admin@your.site command: > /bin/sh -c ' sleep 10; wp user list' # vstm: add shared volume volumes: - ~/wordpress/data:/var/www/html # WP CLI needs the environment variables used for the Wordpress image env_file: ".env" environment: WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME} WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST} WORDPRESS_DB_USER: ${WORDPRESS_DB_USER} WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}