Skip to main content

Local Development with Docker

Comprehensive guide to local development with Seravo's Docker environment. Learn how to use docker-compose, modify configuration files, and utilize Seravo's official Docker images for efficient development.

Updated this week

This article describes how to use Seravo’s local development environment with Docker. Docker is a much more lightweight and secure alternative to traditional virtual machines.

Seravo’s Docker Images

Seravo offers pre-configured Docker images that replicate our production environment. You can find all available versions and tags directly on Docker Hub:

Testing the Image (Quick Start)

Before starting a project-specific setup, you can test the image and download it to your machine (with an empty WordPress installation) by running the following command:

sudo docker run seravo/wordpress

This command pulls the latest image and starts a basic container. For actual project work, we recommend using the Docker Compose method described below.

Requirements

To use the local development environment, you need:

Clone your site to your local device:

git clone https://github.com/examplerepository/example.git cd example

Relevant Files and Their Contents

docker-compose.yml

This file defines the wordpress service. The container reads the SITE environment variable; if missing, it defaults to "wordpress" as the name.

services: 
wordpress:
container_name: ${SITE:-wordpress}
hostname: ${SITE:-wordpress}
image: docker.io/seravo/wordpress:nightly
ports:
- 80
- 443
- 22
- 3306
- 1337
- 1338
- 8080
- 9000
volumes:
- wordpress:/data
- .:/data/wordpress
environment:
#- WP_USER_UID=${WP_USER_UID:-1000}
- DEBUG="true"

Note: If you encounter port conflicts, try declaring them explicitly: 80:80, 443:443, 22:22, etc.

config-sample.yml and config.yml

config.yml defines the URLs and environment behavior. You can copy config-sample.yml to create a new configuration file.

### 
# Configuration for development environment (Vagrant and Docker)
###
name: wordpress
#production:
# This is used to automatically fetch data from a staging/production
environment
#domain: example.seravo.com
#ssh_port: 12345
#url: https://example.seravo.com
development:
# Domains are automatically mapped to Vagrant with /etc/hosts
modifications or Avahi domains:
- wordpress.local
# Allow Vagrant to expose .local domains on the local network (outside
of laptop)
#avahi: true
# If you want to automatically pull stuff from production use 'always'
or set
# to 'never' to just silence the 'yes/no' question during 'vagrant up'.
#pull_production_db: always
#pull_production_plugins: always
#pull_production_themes: always

Starting and Using the Environment

Navigate to the project directory and start the container:

docker-compose up    # Normal mode (logs printed to terminal)
docker-compose up -d # Detached mode (background)

If the startup is successful, you will see this message in the log:

wordpress   | Success!
wordpress | Visit your site at https://wordpress.local/
wordpress | To enter the development environment simply run in the
project directory:
wordpress | ssh wordpress.local -F .vagrant/ssh/config
wordpress | You may also want to execute 'wp-development-up'

Certificate Errors

Browsers will show a security warning because the local site uses a self-signed certificate. You can safely ignore this and click Advanced -> Proceed/Trust this site.

Accessing the Container (SSH)

Note that you cannot access a container through SSH if it is not running.

Even though we use a Docker environment, the connection command uses a path containing .vagrant for legacy SSH configuration compatibility:

ssh wordpress.local -F .vagrant/ssh/config

Once inside the container, you can run wp-development-up. This command imports themes, plugins, and the database from production (if configured in your config.yml file).

Troubleshooting

  1. Verify Configs: Ensure the name in config.yml matches the container_name in docker-compose.yml.

  2. Avahi: If wordpress.local does not open in your browser, ensure avahi: true is set in config.yml.

  3. Update Image: Run docker-compose pull to get the latest version of the Docker image.

  4. Logs: Use docker-compose logs to see what went wrong.

Useful Commands

Command

Description

docker-compose ps

List all containers (add -a to see stopped ones).

docker-compose logs

View log output.

docker-compose down

Stop and remove containers.

docker-compose exec

Execute a command in a running container as root.

docker-compose pull

Update the Docker image in use.

Did this answer your question?