Keep running WP-CLI in Docker container for continuously operation.
Fork of official Docker WordPress image by the Docker Community.
Image on Docker Hub: kumaxim/wpcli-keep-running
Using in terminal:
docker run --rm --name wpcli-running kumaxim/wpcli-keep-running:cli-2.6-php7.4
Using within docker-compose.yml
version '3.1'
services:
wpcli:
image: kumaxim/wpcli-keep-running:cli-2.6-php7.4
Container based on Docker's official wordpress:cli
image will exit after successfully finished wp
command.
This is because CMD
line in official Dockerfile
looks like: CMD ['wp', 'shell']
. The common workaround that allow preventing
stopping container is re-define CMD
option while starting container:
docker-compose.yml
version '3.1'
services:
wpcli:
image: wordpress:cli
command: ['tail', '-f', '/dev/null']
...or in terminal:
docker run --rm --name wpcli wordpress:cli tail -f /dev/null
However, GitHub Actions won't let you override CMD
for service containers.
This image was build to get rid of this problem.
Replace values in CMD
argument in Dockerfile
(s) by default. That is what this image does.
All tags from official Docker WordPress image were preserved.
If you're previously defined base images as:
services:
wpcli:
image: wordpress:cli-2.6-php7.4
...you just need to replace the name:
services:
wpcli:
image: kumaxim/wpcli-keep-running:cli-2.6-php7.4
Full example of using this image in GitHub Actions Workflow may be found inside e2e-tests
job in this pipeline.
Maxim Kudryavtsev. 2022. All rights reserved.
The code in this repository distribute under General Public License version 2 or any later.