Build custom service images
Releasev0.35.0 · cfeceb67
Use a custom Dockerfile to add packages or change a service image. The commands below use MediaWiki; replace mediawiki with another service as needed. Use --context NAME for a separate environment.
Create and edit a Dockerfile
Section titled “Create and edit a Dockerfile”mw dev mediawiki image dockerfile setmw dev mediawiki image dockerfile editWithout a path, set creates or reuses Dockerfile.mediawiki in the environment directory. The starter includes the bundled base image and commented package-installation examples. edit opens it with $VISUAL, $EDITOR, or vi.
To use an existing Dockerfile instead:
mw dev mediawiki image dockerfile set ./docker/mediawiki/DockerfileRelative paths are resolved from your current directory. Keep the base image compatible with the service’s runtime and mounts; the CLI generates the Compose build override for you.
Build and apply changes
Section titled “Build and apply changes”mw dev mediawiki rebuildrebuild builds the image and recreates the service containers. It preserves their volumes and reuses Docker’s build cache. It is equivalent to:
mw dev mediawiki create --build --force-recreateRepeat rebuild after editing the Dockerfile or files it copies. An ordinary create can reuse an existing image and does not guarantee a rebuild. Services using a pre-built image are recreated without a Dockerfile build.
Understand the build context
Section titled “Understand the build context”The directory containing the Dockerfile is the build context. COPY and ADD can only use local files inside that directory. Put a .dockerignore alongside the Dockerfile to exclude credentials, caches and unrelated files from the build context.
A generated starter lives in the environment directory, so that directory is its context. For a build that copies application files, keep an existing Dockerfile alongside those files and activate it with set PATH.
Inspect the active Dockerfile
Section titled “Inspect the active Dockerfile”mw dev mediawiki image dockerfile getmw dev mediawiki image dockerfile catget prints the configured path; cat prints its contents. image get shows the service’s configured image name, and mw dev compose config shows the combined Compose configuration.
Restore the bundled image
Section titled “Restore the bundled image”mw dev mediawiki image dockerfile resetmw dev mediawiki create --force-recreateReset removes the build override but keeps the Dockerfile on disk. Recreating replaces the running containers while preserving their volumes.
A pre-built image selected with image set is a separate override. If one is set, clear it before recreating to return to the bundled image:
mw dev mediawiki image resetmw dev mediawiki create --force-recreateSee service management for lifecycle and image commands.
Read this guide offline with mw help guides dev dockerfiles.
Page views: —Sessions: —