Public | Automated Build

Last pushed: 5 days ago
Short Description
Docker image for Craft CMS.
Full Description

docker-craftcms

Docker image for Craft CMS. Available on Docker Hub as blackpepper/craftcms.

Usage

First start a MySQL database for Craft:

docker run --name database \
    -e MYSQL_ROOT_PASSWORD=password \
    -e MYSQL_USER=craft \
    -e MYSQL_PASSWORD=password \
    -e MYSQL_DATABASE=craft \
    -d mariadb:10

Then run Craft:

docker run --name craftcms \
    -e CRAFT_DATABASE_HOST=database \
    -e CRAFT_DATABASE_USER=craft \
    -e CRAFT_DATABASE_PASSWORD=password \
    -e CRAFT_DATABASE_NAME=craft \
    --link database \
    -p 8080:80 \
    -d blackpepper/craftcms

Visit http://localhost:8080/admin to create a site.

Docker Compose

Alternatively use Docker Compose:

craftcms:
  image: blackpepper/craftcms
  environment:
    CRAFT_DATABASE_HOST: database
    CRAFT_DATABASE_USER: craft
    CRAFT_DATABASE_PASSWORD: password
    CRAFT_DATABASE_NAME: craft
  links:
    - database
  ports:
    - "8080:80"

database:
  image: mariadb:10
  environment:
    MYSQL_ROOT_PASSWORD: password
    MYSQL_USER: craft
    MYSQL_PASSWORD: password
    MYSQL_DATABASE: craft
  ports:
    - "3306:3306"

See the demo project to see this in action.

Configuration

Use the following environment variables to configure Craft at runtime:

Section Variable Name Craft Setting
Database CRAFT_DATABASE_HOST server
CRAFT_DATABASE_PORT port
CRAFT_DATABASE_USER user
CRAFT_DATABASE_PASSWORD password
CRAFT_DATABASE_NAME database
General CRAFT_DEV_MODE devMode
CRAFT_SITE_URL siteUrl
CRAFT_USE_COMPRESSED_JS useCompressedJs
Updates CRAFT_ALLOW_AUTO_UPDATES allowAutoUpdates
URLs CRAFT_OMIT_SCRIPT_NAME_IN_URLS omitScriptNameInUrls
Users CRAFT_COOLDOWN_DURATION cooldownDuration
CRAFT_USER_SESSION_DURATION userSessionDuration
Assets CRAFT_MAX_UPLOAD_FILE_SIZE maxUploadFileSize

Customisation

Use as a base image to customise Craft templates and public assets:

FROM blackpepper/craftcms

ADD templates /var/www/craft/templates
ADD public /var/www/html

Put Craft files under /var/www/craft and
public assets under /var/www/html.

Docker Pull Command
Owner
blackpepper

Comments (0)