It is the first time that I tried to install WordPress in a container, I have used the following from the official docker documentation, but I received the following errors:
version: "3.9"
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:
- wordpress_data:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
wordpress_data: {}
Error:
Creating my_wordpress_db_1 ... done
Creating my_wordpress_wordpress_1 ...
Creating my_wordpress_wordpress_1 ... error
ERROR: for my_wordpress_wordpress_1 Cannot start service wordpress: driver failed programming external connec tivity on endpoint my_wordpress_wordpress_1 (eaa2b38842baac2cbc2126426076f542fd8806509d5d5b19160e07a38f89f173) : Bind for 0.0.0.0:8000 failed: port is already allocated
ERROR: for wordpress Cannot start service wordpress: driver failed programming external connectivity on endpo int my_wordpress_wordpress_1 (eaa2b38842baac2cbc2126426076f542fd8806509d5d5b19160e07a38f89f173): Bind for 0.0. 0.0:8000 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
2
Answers
The error message you have pasted contains a lot of blank spaces which makes the output hard to read. But if you dig through the reason, Docker states the following why your WordPress image will not work.
The solution is to figure out which other resource is allocating port
8000
and close that program. It might be some other docker instance running, trydocker ps -a
to view all docker images. Alternatively you may specify a different port in yourdocker-compose.yml
-file.You can try
In your example you have
8000:80
You made a change to compiled information after running:
npm run build:dev
In my case I had manually modified /etc/hosts after compiling the build.
This broke referenced paths in the build.
Re-running
npm run build:dev
fixes the issue.