Sign inSign up

PHP Development Container Images

Verified Publisher

devcontainers/php

By Microsoft

•Updated over 2 years ago

A dev container spec-supported image for working with PHP.

3

microsoft/devcontainers-php repository overview

⁠PHP

⁠About

Develop PHP based applications. Includes needed tools, extensions, and dependencies.

MetadataValue
CategoriesLanguages
Image typeDockerfile
Published imagesmcr.microsoft.com/devcontainers/php
Available image variants8 / 8-trixie, 8.5 / 8.5-trixie, 8.4 / 8.4-trixie, 8.3 / 8.3-trixie, 8-bookworm, 8.5-bookworm, 8.4-bookworm, 8.3-bookworm (full list⁠)
Published image architecture(s)x86-64, arm64/aarch64 for trixie, bookworm variants
Container host OS supportLinux, macOS, Windows
Container OSDebian
Languages, platformsPHP

See history⁠ for information on the contents of published images.

⁠Using this image

You can directly reference pre-built versions of Dockerfile by using the image property in .devcontainer/devcontainer.json or updating the FROM statement in your own Dockerfile with one of the following:

  • mcr.microsoft.com/devcontainers/php (latest)
  • mcr.microsoft.com/devcontainers/php:8 (or 8-trixie, 8-bookworm to pin to an OS version)
  • mcr.microsoft.com/devcontainers/php:8.5 (or 8.5-trixie, 8.5-bookworm to pin to an OS version))
  • mcr.microsoft.com/devcontainers/php:8.4 (or 8.4-trixie, 8.4-bookworm to pin to an OS version)
  • mcr.microsoft.com/devcontainers/php:8.3 (or 8.3-trixie, 8.3-bookworm to pin to an OS version)

Refer to this guide⁠ for more details.

You can decide how often you want updates by referencing a semantic version⁠ of each image. For example:

  • mcr.microsoft.com/devcontainers/php:4-8 (or 4-8-trixie, 4-8-bookworm)
  • mcr.microsoft.com/devcontainers/php:4.1-8 (or 4.1-8-trixie, 4.1-8-bookworm)
  • mcr.microsoft.com/devcontainers/php:4.1.2-8 (or 4.1.2-8-trixie, 4.1.2-8-bookworm)

However, we only do security patching on the latest non-breaking, in support⁠ versions of images (e.g. 4-8). You may want to run apt-get update && apt-get upgrade in your Dockerfile if you lock to a more specific version to at least pick up OS security updates.

See history⁠ for information on the contents of each version and here for a complete list of available tags⁠.

Alternatively, you can use the contents of .devcontainer⁠ to fully customize your container's contents or to build it for a container host architecture not supported by the image.

⁠Installing Node.js

Given JavaScript front-end web client code written for use in conjunction with a PHP back-end often requires the use of Node.js-based utilities to build, this container also includes nvm so that you can easily install Node.js.

Also, you can use a Node feature⁠ to install any version of Node by adding the following to devcontainer.json:

{
  "features": {
    "ghcr.io/devcontainers/features/node:1": {
      "version": "latest"
    }
  }
}
⁠Starting / stopping Apache

This dev container includes Apache in addition to the PHP CLI. While you can use PHP's built in CLI (e.g. php -S 0.0.0.0:8080), you can start Apache by running:

apache2ctl start

Apache will be available on port 8080.

If you want to wire in something directly from your source code into the www folder, you can add a symlink as follows to postCreateCommand:

"postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"

...or execute this from a terminal window once the container is up:

sudo chmod a+x "$(pwd)" && sudo rm -rf /var/www/html && sudo ln -s "$(pwd)" /var/www/html

⁠Support

The dev container spec images are maintained in the devcontainers/images⁠ repo. You can explore each image and open issues or feature requests.

⁠License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE⁠.

Tag Summary

No tags have been pushed to this repository yet.