Lightweight WordPress Docker Image using Alpine

Overview

The dishoneprabu/wordpress-alpine:latest Docker image is a lightweight, efficient, and easy-to-use WordPress setup built on the Alpine Linux base. By utilizing Alpine, this image offers a smaller size and faster startup times compared to traditional WordPress images, making it ideal for users who want a simple and resource-efficient WordPress deployment.

Why Use This Image?

  • Small Footprint: Based on Alpine Linux, which is known for its minimalistic design, the image is significantly smaller than other WordPress images, reducing disk space usage.
  • Faster Startup: Alpine’s lightweight nature allows faster container startup times, improving deployment speed.
  • Resource Efficiency: Ideal for environments with limited resources such as small VPS instances or development environments where every megabyte counts.
  • Customizable: Easily extendable with plugins and themes to meet specific requirements.

Getting Started

Here’s how to get up and running with dishoneprabu/wordpress-alpine:latest on Docker:

Prerequisites

  • Docker installed on your system.
  • A running MySQL or MariaDB instance, which WordPress requires for storing content.

Step 1: Pull the Image

To get the latest version of the image, use the following command:

docker pull dishoneprabu/wordpress-alpine:latest

Step 2: Start a MySQL Container

If you don’t have an existing MySQL instance, you can quickly set one up using Docker:

docker run --name wordpress-db -e MYSQL_ROOT_PASSWORD=rootpassword -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpressuser -e MYSQL_PASSWORD=wordpresspassword -d mysql:5.7
  • Replace rootpassword, wordpressuser, and wordpresspassword with your desired values.
  • This command creates a new MySQL container named wordpress-db and sets up a wordpress database.

Step 3: Run the WordPress Container

After setting up the database, you can start the WordPress container:

docker run --name wordpress -e WORDPRESS_DB_HOST=wordpress-db:3306 -e WORDPRESS_DB_USER=wordpressuser -e WORDPRESS_DB_PASSWORD=wordpresspassword -e WORDPRESS_DB_NAME=wordpress -p 8080:80 -d dishoneprabu/wordpress-alpine:latest
  • This command will start the dishoneprabu/wordpress-alpine:latest container, mapping port 80 of the container to port 8080 on your local machine.
  • Replace the environment variables with the appropriate values matching your database setup.

Step 4: Access Your WordPress Site

Once the container is up and running, you can access your WordPress site by visiting:

http://localhost:8080

Follow the setup wizard to configure your new WordPress site.

Customizing the Image

The dishoneprabu/wordpress-alpine:latest image can be customized to suit your needs:

  • Adding Plugins: You can add WordPress plugins either by logging into the WordPress admin interface or by mounting a volume to the wp-content/plugins directory.
  • Themes: Similarly, you can install themes through the WordPress admin interface or by mounting a volume to the wp-content/themes directory.
  • Persistent Storage: To persist data, map a local directory to /usr/html in the container:
docker run --name wordpress -v /path/to/local/directory:/usr/html -e WORDPRESS_DB_HOST=... -p 8080:80 -d dishoneprabu/wordpress-alpine:latest

This ensures that any changes made to your WordPress site, such as uploaded images or installed plugins, are not lost when the container restarts.

Example Docker Compose Configuration

For easier management, you can use Docker Compose:

version: '3.1'<br><br>services:<br>  wordpress:<br>    image: dishoneprabu/wordpress-alpine:latest<br>    restart: always<br>    ports:<br>      - 8080:80<br>    environment:<br>      WORDPRESS_DB_HOST: wordpress-db:3306<br>      WORDPRESS_DB_USER: wordpressuser<br>      WORDPRESS_DB_PASSWORD: wordpresspassword<br>      WORDPRESS_DB_NAME: wordpress<br>    volumes:<br>      - ./wordpress:/usr/html<br><br>  wordpress-db:<br>    image: mysql:5.7<br>    restart: always<br>    environment:<br>      MYSQL_ROOT_PASSWORD: rootpassword<br>      MYSQL_DATABASE: wordpress<br>      MYSQL_USER: wordpressuser<br>      MYSQL_PASSWORD: wordpresspassword<br>    volumes:<br>      - ./mysql:/var/lib/mysql<br>
  • Save this as docker-compose.yml and run:
docker-compose up -d
  • This configuration will spin up both WordPress and MySQL containers, with persistent storage for both WordPress data and the MySQL database.

Security Scan Results

The dishoneprabu/wordpress-alpine:latest image has undergone a security scan using Trivy, a popular vulnerability scanner for Docker images.

Security Scan:

Conclusion

The dishoneprabu/wordpress-alpine:latest Docker image offers a compact and efficient way to host WordPress using Docker. Its Alpine base makes it a great choice for developers and hobbyists looking for a lightweight WordPress solution without compromising on functionality. With the flexibility to scale and customize, this image is ideal for both local development and production environments.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *