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:
Docker and Docker Compose installed.
Git installed.
WordPress site in Git version control (mandatory for Seravo's helper commands).
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
Verify Configs: Ensure the
nameinconfig.ymlmatches thecontainer_nameindocker-compose.yml.Avahi: If
wordpress.localdoes not open in your browser, ensureavahi: trueis set inconfig.yml.Update Image: Run
docker-compose pullto get the latest version of the Docker image.Logs: Use
docker-compose logsto see what went wrong.
Useful Commands
Command | Description |
| List all containers (add |
| View log output. |
| Stop and remove containers. |
| Execute a command in a running container as root. |
| Update the Docker image in use. |
