I am trying to install wordpress using Docker Desktop and WSL2.
I was able to compose an image creating the following docker-compose.yml file and then running docker-compose up
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
(This is taken from the official wordpress image's page on docker hub. I have change the default environment variables for DB_USER, DB_PASSWORD and DB_NAME but they were set equal to MYSQL_USER, MYSQL_PASSWORD and MYSQL_DATABASE respectively.)
Back to Docker Desktop, I ran the container, which seems to work correctly because when I got to localhost:8080 I find Wordpress' first setup process. However, when I plug-in the database name, username, password and host that I used in the file I get the error "Error establishing a database connection".
I tried the following for as Database host, but none worked: localhost, localhost:8080, localhost:80 and db.
Any idea?
Related
I'm using the below stack to try and install WordPress on an ARM based computer but I keep getting an error in Portainer when I try and deploy the stack.
I'm running:
Docker Version: 5:20.10.17~3-0~debian-bullseye
Portainer version: 2.14.0
I get the following error:
failed to deploy a stack: db
Pulling wordpress
Pulling b84950154c18
Pulling fs layer b1ae07faadba
Pulling fs layer 46428e702eff
Pulling fs layer 0e775e0ed5a0
The list is actually much longer than this, I can paste the whole thing if necessary, but it is a lot of "Pulling fs layer {numbers and letters}"
Here is the stack I'm using:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8484:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: gibblebreath
WORDPRESS_DB_PASSWORD: chickpea655
WORDPRESS_DB_NAME: wpdb
volumes:
- /srv/dev-disk-by-label-Files/Configs/WordPress:/var/www/html
links:
- db:db
db:
image: yobasystems/alpine-mariadb:latest
restart: always
environment:
MYSQL_DATABASE: wpdb
MYSQL_USER: gibblebreath
MYSQL_PASSWORD: chickpea655
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- /srv/dev-disk-by-label-Files/Databases/WordPress/db:/var/lib/mysql
volumes:
wordpress:
db:
I've tried other databse images, including mysql:latest, docker.io/bitnami/mariadb:10.7 and others but the same error occurs each time. I've also restarted both docker and portainer.
Any advice would be hugely appreciated.
I'm developing a woocommerce shop. To do that I use docker on my localhost, and DB which is located on the remote server. My local machine is windows 10 home (so i use docker toolbox). To set my locl env I use docker-compose.yaml, which you can see below:
version: '3'
services:
# Wordpress
wordpress:
image: wordpress:latest
ports:
- '8000:80'
restart: always
volumes: ['./:/var/www/html:delegated']
environment:
WORDPRESS_DB_HOST: WORDPRESS_DB_HOST
WORDPRESS_DB_NAME: 'WORDPRESS_DB_NAME'
WORDPRESS_DB_USER: 'WORDPRESS_DB_USER'
WORDPRESS_DB_PASSWORD: WORDPRESS_DB_PASSWORD
networks:
- wpsite
networks:
wpsite:
The above config works, but its super slow. Does anyone know how to speed this up?
I started working with Docker for WordPress. I followed the docker documentation to get it up and running:
https://docs.docker.com/compose/wordpress/
I added volumes for the plugin & theme directory.
When ran the command docker-compose up -d the first time and went to http://localhost:8000/ i saw the installation of WordPress. When i rebooted my PC and started the services again with: docker-compose up -d or docker-compose start i got the error message: ERR_EMPTY_RESPONSE.
I tried:
Removing the containers, services and volumes
Killing the netstat port
Currently I have no idea why it isn't working anymore. I am working on macOS
This is my current docker-compose.yml
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- ./plugins/my-plugin:/var/www/html/wp-content/plugins/my-plugin
- ./themes/my-theme:/var/www/html/wp-content/themes/my-theme
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpres
volumes:
db_data: {}
The status of containers after running it:
Follow these steps
docker-compose down - twice
Edit the yml file and replace all instances of db_data with db_datax
Run docker-compose up -d
Alternately,
docker-compose down - twice {removes the network as well}
docker system prune --volumes
docker-compose up -d
I'm trying to set up a simple WordPress build using docker compose. However, when I build it, the volumes appear to be empty.
Here is my docker-compose.yml:
version: '3'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8000:80
volumes:
- ./development:/var/www/html
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
depends_on:
- db
networks:
- wordpress-network
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
ports:
- 8080:80
links:
- db:db
db:
image: mariadb:latest
ports:
- 127.0.0.1:3306:3306
command: [
'--default_authentication_plugin=mysql_native_password',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci'
]
volumes:
- wp-data:/var/lib/mysql
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: password
networks:
- wordpress-network
networks:
wordpress-network:
driver: bridge
volumes:
wp-data:
driver: local
Here is my local project structure, with theme stylesheet:
I run docker-compose to build the image:
docker-compose up -d --build
But when I open the build in my browser, it looks like the theme is empty:
This leads me to believe the volume is empty. I'd appreciate any help or insights into this issue, thank you.
In your docker-compose file you say ./wp-data:/var/lib/mysql which is host folder mapping (not volume) but in your docker-compose you define docker named volume called wp-data and if you want to use this volume you have to use it as wp-data:/var/lib/mysql. I would also suggest to remove ${PWD} because it might cause problem in sh
I'm try to setup a docker workspace with Alpine, PHP, Apache, MySQL and Composer.
Currently I'm trying to use the following images:
PHP, Alpine and Composer: https://hub.docker.com/r/petehouston/docker-alpine-php-composer/
Wordpress: https://hub.docker.com/_/wordpress/
I created a docker-compose.yml file to manage this dependencies for me.
docker-compose.yml
version: '2'
services:
db:
image: mysql:5.7
volumes:
- ./db:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- ./www:/var/www/html
links:
- db
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
alpine:
image: petehouston/docker-alpine-php-composer:latest
links:
- wordpress
So my problem is I'm trying to use the composer of the alpine container to manager my Wordpress in the wordpress container but when i try to use the following command:
docker run --rm -v $(pwd):/www -w /wordpress/var/www/html composer/composer create-project roots/sage your-theme-name 8.5.0
nothing happens, and the alpine container doesn't stay up, after i run compose-docker.up he exits
You can't access to Wordpress container from Alpine container using -w /wordpress/var/www/html.
As far as I understand, image petehouston/docker-alpine-php-composer:latest provides PHP deployment environment. That means you should use this image instead of wordpress image.
Your compose file can be like
version: '2'
services:
db:
image: mysql:5.7
volumes:
- ./db:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
alpine:
image: petehouston/docker-alpine-php-composer:latest
volumes:
- ./www:/home
links:
- db
ports:
- "8000:80"
command: composer require phpunit/phpunit
restart: always
Plz give me feedback. I'm sorry because i can't comment to get more information from you. Should you still get errors, comment here. I'll recheck