简体   繁体   中英

How to add wp-cli to docker wordpress?

Is there a way to do this without having to go into the container and install it? Seems kind of weird they wouldn't include this with the Wordpress image. Anyway - Heres what I have at the moment. How would you do this?

version: '3.3'
services:
  db:
    image: mysql
    restart: always
    volumes:
    - mysql_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=admin
      - MYSQL_DATABASE=admin
      - MYSQL_USER=admin
      - MYSQL_PASSWORD=admin
  wordpress:
    image: wordpress
    depends_on:
      - db
    ports:
      - '1234:80'
    restart: always
    volumes:
      - ./wp-content:/var/www/html/wp-content
    environment:
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_USER=admin
      - WORDPRESS_DB_PASSWORD=admin
      - WORDPRESS_DB_NAME=admin
      - WORDPRESS_TABLE_PREFIX=admin
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - '8080:80'
    environment:
      - PMA_HOST=db
      - MYSQL_ROOT_PASSWORD=admin
volumes:
  mysql_data:
    driver: local

You can use one of the images tagged with cli , such as:

image: worpress:cli-php7.4

Find the list of available tags on Docker Hub

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM