Running wordpress on docker. Trying to skip install install.php by defining user in compose file. I have already added wordpress user , password and title to skip that page. but not working.
Is there some problem with my code? Is there another way to do it. or help me fix this code.
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:
- ./wordpress:/var/www/html
- ./docker/wordpress/php/php.ini:/usr/local/etc/php/conf.d/php.ini:ro
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_VERSION: 5.1
WORDPRESS_LOCALE: en_US
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_TABLE_PREFIX: "wp_"
WORDPRESS_DEBUG: 1
WORDPRESS_DB_NAME: wordpress
# WORDPRESS_WEBSITE_TITLE: "My blog"
# WORDPRESS_WEBSITE_URL: "http://example.com"
# WORDPRESS_WEBSITE_URL_WITHOUT_HTTP: "example.com"
# WORDPRESS_WEBSITE_URL: "http://http://localhost:8000"
# WORDPRESS_WEBSITE_URL_WITHOUT_HTTP: "localhost"
# WORDPRESS_WEBSITE_POST_URL_STRUCTURE: "/%year%/%monthnum%/%day%/%postname%/"
# WORDPRESS_ADMIN_USER: "admin"
# WORDPRESS_ADMIN_PASSWORD: "admin"
# WORDPRESS_ADMIN_EMAIL: "admin@admin.com"
working_dir: /var/www/html
wordpress-cli:
depends_on:
- db
- wordpress
image: wordpress:cli
entrypoint: wp
user: xfs
command: >
/bin/sh -c ' sleep 10;
wp core install --url="http://localhost:8000" --title="Sample Title" --admin_name=admin --admin_password=admin --admin_email=you@domain.com '
volumes:
- ./wordpress:/var/www/html
- ./docker/wordpress/php/php.ini:/usr/local/etc/php/conf.d/php.ini:ro
volumes:
db_data: {}
wordpress:
Got this error:
C:\DockerProjects\test6>docker-compose up
ERROR: yaml.scanner.ScannerError: while scanning a simple key
in ".\docker-compose.yml", line 54, column 6
could not find expected ':'
in ".\docker-compose.yml", line 55, column 6
Problem is in this part of code
user: xfs
command: >
/bin/sh -c ' sleep 10;
wp core install --url="http://localhost:8000" --title="Sample Title" --admin_name=admin --admin_password=admin --admin_email=you@domain.com '
It has to be like this
user: xfs
command: >
/bin/sh -c ' sleep 10;
wp core install --url="http://localhost:8000" --title="Sample Title" --admin_name=admin --admin_password=admin --admin_email=you@domain.com '
after command: >
next 2 lines you need to give 1 Tab.
You can check your code with online formatter here.
Edit 1:
Formatted Code looks like this
version: '3.3'
services:
db:
image: 'mysql:5.7'
volumes:
- './db-data:/var/lib/mysql'
restart: always
environment: null
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: 'wordpress:latest'
volumes:
- './wordpress:/var/www/html'
- './docker/wordpress/php/php.ini:/usr/local/etc/php/conf.d/php.ini:ro'
ports:
- '8000:80'
restart: always
environment: null
WORDPRESS_VERSION: 5.1
WORDPRESS_LOCALE: en_US
WORDPRESS_DB_HOST: 'db:3306'
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_DEBUG: 1
WORDPRESS_DB_NAME: wordpress
working_dir: /var/www/html
wordpress-cli:
depends_on:
- db
- wordpress
image: 'wordpress:cli'
entrypoint: wp
user: xfs
command: "/bin/sh -c ' sleep 10; wp core install --url=\"http://localhost:8000\" --title=\"Sample Title\" --admin_name=admin --admin_password=admin --admin_email=you@domain.com '\n"
volumes:
- './wordpress:/var/www/html'
- './docker/wordpress/php/php.ini:/usr/local/etc/php/conf.d/php.ini:ro'
volumes:
db_data: {}
wordpress: null
You can install wordpress Cli either in the compose file. or you can copy the wp cli into the image using dockerfile and install wordpress using custom entrypoint.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.