The Wayback Machine - https://web.archive.org/web/20160305022858/https://docs.docker.com/compose/wordpress/
Get Started
Quickstart containers Understand the architecture
Migrate to Engine 1.10 Breaking changes Deprecated Engine Features FAQ
Release Notes
Learn about Dockerfiles and Docker Cloud Back up data volumes Create a proxy or load balancer Install the Deploy to Docker Cloud button Integrate with Slack Push images to Docker Cloud SSHing into a Docker Cloud-managed node Upgrade Docker Engine on a node Use the Docker Cloud Agent Using the Docker Cloud CLI
API reference
Quickstart contribution FAQ for contributors Where to chat or get help Style guide for Docker documentation

Quickstart: Docker Compose and WordPress

You can use Docker Compose to easily run WordPress in an isolated environment built with Docker containers. This quick-start guide demonstrates how to use Compose to set up and run WordPress. Before starting, you’ll need to have Compose installed.

Define the project

  1. Create an empty project directory.

    You can name the directory something easy for you to remember. This directory is the context for your application image. The directory should only contain resources to build that image.

    This project directory will contain a Dockerfile, a docker-compose.yaml file, along with a downloaded wordpress directory and a custom wp-config.php, all of which you will create in the following steps.

  2. Change directories into your project directory.

    For example, if you named your directory my_wordpress:

    $ cd my-wordpress/
    
  3. Create a Dockerfile, a file that defines the environment in which your application will run.

    For more information on how to write Dockerfiles, see the Docker Engine user guide and the Dockerfile reference.

    In this case, your Dockerfile should include these two lines:

    FROM orchardup/php5
    ADD . /code
    

    This tells the Docker Engine daemon how to build an image defining a container that contains PHP and WordPress.

  4. Create a docker-compose.yml file that will start your web service and a separate MySQL instance:

    version: '2'
    services:
      web:
        build: .
        command: php -S 0.0.0.0:8000 -t /code/wordpress/
        ports:
          - "8000:8000"
        depends_on:
          - db
        volumes:
          - .:/code
      db:
        image: orchardup/mysql
        environment:
          MYSQL_DATABASE: wordpress
    
  5. Download WordPress into the current directory:

    $ curl https://wordpress.org/latest.tar.gz | tar -xvzf -
    

    This creates a directory called wordpress in your project directory.

  6. Create a wp-config.php file within the wordpress directory.

    A supporting file is needed to get this working. At the top level of the wordpress directory, add a new file called wp-config.php as shown. This is the standard WordPress config file with a single change to point the database configuration at the db container:

    <?php
    define('DB_NAME', 'wordpress');
    define('DB_USER', 'root');
    define('DB_PASSWORD', '');
    define('DB_HOST', "db:3306");
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');
    
    define('AUTH_KEY',         'put your unique phrase here');
    define('SECURE_AUTH_KEY',  'put your unique phrase here');
    define('LOGGED_IN_KEY',    'put your unique phrase here');
    define('NONCE_KEY',        'put your unique phrase here');
    define('AUTH_SALT',        'put your unique phrase here');
    define('SECURE_AUTH_SALT', 'put your unique phrase here');
    define('LOGGED_IN_SALT',   'put your unique phrase here');
    define('NONCE_SALT',       'put your unique phrase here');
    
    $table_prefix  = 'wp_';
    define('WPLANG', '');
    define('WP_DEBUG', false);
    
    if ( !defined('ABSPATH') )
      define('ABSPATH', dirname(__FILE__) . '/');
    
    require_once(ABSPATH . 'wp-settings.php');
    ?>
    
  7. Verify the contents and structure of your project directory.

    WordPress files

Build the project

With those four new files in place, run docker-compose up from your project directory. This will pull and build the needed images, and then start the web and database containers.

If you’re using Docker Machine, then docker-machine ip MACHINE_VM gives you the machine address and you can open http://MACHINE_VM_IP:8000 in a browser.

At this point, WordPress should be running on port 8000 of your Docker Host, and you can complete the “famous five-minute installation” as a WordPress administrator.

Choose language for WordPress install

WordPress Welcome

More Compose documentation

Mar 5, 2016 at 2:08am (PST) { "docker/apidocs": { "ref": "master", "repos": [ "[email protected]:docker/dhe-deploy.git" ], "sha": "70ac255c88cde0ea6ecf3fcb812783dea7e09da6" }, "docker/cloud-api-docs": { "ref": "master", "repos": [ "[email protected]:docker/cloud-docs.git" ], "sha": "c0539949c40be9abb193271e46d2ea88196f122d" }, "docker/cloud-api-docs-layout": { "ref": "master", "repos": [ "[email protected]:docker/cloud-docs.git" ], "sha": "c0539949c40be9abb193271e46d2ea88196f122d" }, "docker/compose": { "ref": "docs", "repos": [ "[email protected]:docker/compose.git" ], "sha": "9da9555f10abe628e7742476af3f10bd89f68b75" }, "docker/docker": { "ref": "docs", "repos": [ "[email protected]:docker/docker.git" ], "sha": "0e63b073ac8f33335a4d4df3f2aa22120e0b7f43" }, "docker/docker-cloud": { "ref": "master", "repos": [ "[email protected]:docker/cloud-docs.git" ], "sha": "c0539949c40be9abb193271e46d2ea88196f122d" }, "docker/docker-hub": { "ref": "master", "repos": [ "[email protected]:docker/hub2-demo.git" ], "sha": "73ccb2d678ab0cd83067f0c7ef6f3923d750c7bd" }, "docker/docker-trusted-registry": { "ref": "master", "repos": [ "[email protected]:docker/dhe-deploy.git" ], "sha": "70ac255c88cde0ea6ecf3fcb812783dea7e09da6" }, "docker/docs-base": { "ref": "master", "repos": [ "[email protected]:docker/docs-base.git" ], "sha": "5a4cfac3c4d156eda45080c7dcdd2a4c41e08067" }, "docker/kitematic": { "ref": "docs", "repos": [ "[email protected]:docker/kitematic.git" ], "sha": "856a989d834f7fcbcb9bba687539fb159228f6b8" }, "docker/machine": { "ref": "docs", "repos": [ "[email protected]:docker/machine.git" ], "sha": "21edf30337dc5996b5d785ce54d68b4020242f57" }, "docker/notary": { "ref": "docs", "repos": [ "[email protected]:docker/notary.git" ], "sha": "dfeb51f54f2b0cdf20cb55427b7cc8ea2d1cdd0a" }, "docker/opensource": { "ref": "master", "repos": [ "[email protected]:docker/opensource.git" ], "sha": "b994cdd1f74b0aeb0b51fda1249a0c4c8efbf0d0" }, "docker/registry": { "ref": "master", "repos": [ "[email protected]:docker/distribution.git" ], "sha": "33c4a6522e9247913fa0a9a2d78ef9a7aa98465f" }, "docker/swarm": { "ref": "docs", "repos": [ "[email protected]:docker/swarm.git" ], "sha": "b43a2c21c4017726cd9cb17ef9b16f2eef6d1159" }, "docker/toolbox": { "ref": "master", "repos": [ "[email protected]:docker/toolbox.git" ], "sha": "de267d701f94035549ea03e68047d85534286f85" }, "docker/tutorials": { "ref": "master", "repos": [ "[email protected]:docker/tutorials.git" ], "sha": "7af2622fe68a30684d971e4bf3ca7988902e5e26" }, "docker/ucp": { "ref": "master", "repos": [ "[email protected]:docker/orca.git" ], "sha": "8cd10936a1e063b9be0d5c04de7311a1b2cb25cf" }, "docs.docker.com": { "ref": "refs/heads/v1.10-030316", "repos": [ "[email protected]:moxiegirl/docs.docker.com.git", "[email protected]:docker/docs.docker.com.git" ], "sha": "b43886e4078ce481b06b4cee5c922f5bcc5c629f" } }