I have a website which i want to containerised i tried following the steps mentioned on this link
i have my files copied to /var/www/html/example.com/src/ and also my docker-compose file looks like this :
version: '2'
services:
example_db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: ${WP_DB_USER_PASSWORD}
MYSQL_DATABASE: ${WP_DB_NAME}
volumes:
- /var/lib/mysql:/docker-entrypoint-initdb.d/example.sql
container_name: example_db
restart: always
example:
depends_on:
- example_db
image: wordpress:5.0.0-php5.6-apache # we're using the image with php7.1
environment:
WORDPRESS_DB_PASSWORD: ${WP_DB_USER_PASSWORD}
WORDPRESS_DB_NAME: ${WP_DB_NAME}
container_name: example
ports:
- "1512:80"
restart: always
links:
- example_db:mysql
volumes:
- ./src:/var/www/html/docker/example.com/src/
i have my wordpress file in /www/html/docker/example.com/src/ and the db backup inside /src/docker/example.com/data/docker-entrypoint-initdb.d/lbdocker.sql
every time i acces the website it goes to the WordPress setup guide.
this is old but the issue is related to the $table_prefix
Your backup table prefix is different than the destination.
Update your config and it will work.
Fix
Related
There is a question that asks about volumes, mine is a bit different.
What I'm interested in is that when I use a simple docker-compose.yml file
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: user
MYSQL_PASSWORD: password
app:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
volumes:
- .:/var/www/html/
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: user
WORDPRESS_DB_PASSWORD: password
volumes:
db_data:
The default image somehow downloads the entire WordPress installation to my host. How does it do that?
I'm asking, because I have a custom Dockerfile in which I ADD the wp zip file, unzip it and put the contents to /var/www/html which is mapped in my docker-compose.yml file in the ../:/var/www/html (my docker-compose.yml file is in the project-root/.docker/ folder so I map the project root to the WP root).
When I tried with the official image the contents were copied to my host, so I'm clearly missing some crucial part that is in the official images. But which one?
So it turns out that you have to copy/download/install using wpcli the WP inside the entrypoint script, and native WP docker images are doing that. Either that or inside the CMD command.
It's the same with this question.
Once done there, all the files in the container will appear in the host as well.
I'm trying to build a docker based WordPress development environment and I want to be able to have a folder structure like this:
.
|
--wp-data
|
--wp-content
|
--plugins
|
--themes
where plugins and themes are also inside wp-content
this is my docker-compose file:
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- ./wp-data:/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
ports:
- '8000:80'
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content/
- ./themes:/var/www/html/wp-content/themes/
- ./plugins:/var/www/html/wp-content/plugins/
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
wp-data:
wp-content:
themes:
plugins:
the wp-data and w-content are created ok
but the nested themes and plugins arent
what im missing?
Regards
You are misusing volumes. In your docker-compose.yml you create bind mounts for each service - that means you mount a particular directory of the host into containers.
At the same time you are declaring a section volumes where explicitly declare volumes with the same names, but they are never used and created as empty directories.
Of you want to create and use volumes, you need to rewrite your docker-compose.yml in the following manner:
services:
...
db:
...
volumes:
- wp-data:/var/lib/mysql
...
wordpress:
volumes:
- wp-content:/var/www/html/wp-content/
- themes:/var/www/html/wp-content/themes/
- plugins:/var/www/html/wp-content/plugins/
volumes:
wp-data:
wp-content:
themes:
plugins:
This will enable volumes, but you still need a way to put data from host into them (like docker cp for example).
From the other hand, of you intended to use bind mounts, you need to completely remove ending volumes: section not to get confused.
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 am using Wordpress and docker container. The problem is that I updated the wp-config.php file but everything looks the same.
I have something like this:
CONTAINER ID IMAGE NAMES
b2711d4b72a1 phpmyadmin/phpmyadmin website_phpmyadmin_1
8a89ee46d673 wordpress:4.7.5 website_wordpress_1
2a167667f705 mysql:5.7 website_db_1
My docker-compose.yaml looks like this:
version: '2'
services:
wordpress:
depends_on:
- db
image: wordpress:4.7.5
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: p4ssw0rd!
ports:
- 80:80
- 443:443
networks:
- back
db:
image: mysql:5.7
restart: always
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: p4ssw0rd!
networks:
- back
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 8080:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: p4ssw0rd!
networks:
- back
networks:
back:
volumes:
db_data:
I have run docker-compose up, build and down but everything is the same.
The official WordPress docker image will automatically configure wp-config.php using the environment variables you set [documentation].
If there are any variables such as WORDPRESS_DB_HOST, WORDPRESS_DB_PASSWORD, etc., they will be used to build a wp-config.php file upon container creation.
If you want to provide a custom wp-config.php file, you need to make sure there are no related environment variables, and create a volume mapping for your modified file, like so:
version: '2'
...
volumes:
- ./wp-content:/var/www/html/wp-content
- ./wp-config.php:/var/www/html/wp-config.php
...
On docker-compose up, Docker will load your custom wp-config.php into the container and then run the WordPress image's docker-entrypoint.sh which updates the file with the values set in your environment variables.
You can make use of the WORDPRESS_CONFIG_EXTRA environment variable to define any other config values in the wp-config.php file.
As an example:
WORDPRESS_CONFIG_EXTRA: |
define('WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
The trick:
wp:
image: wordpress:latest
ports:
- 80:80
volumes:
- ./wp-content:/var/www/html/wp-content
- ./wp-config.php:/usr/src/wordpress/wp-config-sample.php
When local wp-config.php changes you should delete /var/www/html/wp-config.php from container, docker will copy it again... but it works!
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