Running PHP 8.6 Beta CLI in Docker
Scott Keck-Warren • October 2, 2026
I'm working on my yearly "What's new and exciting in PHP 8.x" video (if you're interested, see my PHP 8.1, PHP 8.2, PHP 8.3, PHP 8.4, PHP 8.5 videos) for PHP 8.6. One of the things I've learned the hard way is to always test that my code samples are valid because people will complain. To do that, I need to be running the most current release of PHP 8.6, but I don't want to install a beta version of PHP on my laptop that I use every day, so I like to run it using Docker.
I try to keep it super simple using a Makefile to run it (because I'm terrible at remembering the Docker commands) and a basic Dockerfile so I can run the PHP CLI or bash for debugging. It also keeps track of whether the Dockerfile has changed so we don't rebuild the image if we can help it.
Makefile
IMAGE := php86
TTY := $(shell [ -t 0 ] && echo -t)
STAMP := .build
.PHONY: build run shell clean
build: $(STAMP)
$(STAMP): Dockerfile
docker build -t $(IMAGE) .
@touch $(STAMP)
run: $(STAMP)
docker run --rm -i $(TTY) -v $(CURDIR):/app $(IMAGE)
shell: $(STAMP)
docker run --rm -i $(TTY) -v $(CURDIR):/app $(IMAGE) bash
clean:
rm -f $(STAMP)
Dockerfile
# change this to beta3 when it's released
FROM php:8.6.0beta2-cli
WORKDIR /app
CMD ["php", "-a"]
Usage
Then, to use it, you just need to call make run to get an interactive PHP shell (php -a):
make run
docker run --rm -i -t -v /Users/scottkeck-warren/tmp/php86:/app php86
Interactive shell
php > echo PHP_VERSION;
8.6.0beta2
AI notice:
The outline for this post was generated via AI, then I wrote the prose and ran it through Grammarly