This repository has been containerized to run easily with Docker and Docker Compose.
- Docker (version 20.10 or higher)
- Docker Compose (version 1.29 or higher)
- Make (optional, for using the Makefile commands)
-
Clone the repository
-
Run the setup command:
make setup
Or without Make:
docker-compose up -d
-
Access the application:
- Application: http://localhost
- PhpMyAdmin: http://localhost:8080
The Docker setup includes three services:
- web: PHP 5.6 with Apache serving the application on port 80
- mysql: MySQL 5.7 database server
- phpmyadmin: Web interface for database management on port 8080
WebGoatPHP was last updated in 2016 and includes older versions of dependencies (like Doctrine ORM) that are incompatible with modern PHP versions. Using PHP 5.6 ensures:
- Full compatibility with the application code
- No need to modify or update dependencies
- The application runs as originally intended
The database configuration is automatically handled by the Docker entrypoint script:
- Database name:
webgoatphp - Database user:
webgoatuser - Database password:
webgoatpass - Root password:
rootpassword
The script will:
- Wait for MySQL to be ready
- Update the application configuration to use the correct database host
- Create the database if it doesn't exist
- Import the initial schema if the database is empty (with foreign key checks disabled)
If you have Make installed:
make build- Build Docker imagesmake up- Start containersmake down- Stop containersmake setup- Complete setup (build, start, configure)make logs- View container logsmake shell- Access web container shellmake mysql-shell- Access MySQL shellmake clean- Remove containers and volumesmake status- Check container statusmake db-init- Manually initialize database (if automatic fails)make rebuild- Clean and rebuild everything from scratch
If you see a database connection error, the entrypoint script should handle this automatically. If issues persist:
- Check logs:
docker-compose logs web - Ensure MySQL is running:
docker-compose ps - Manually run the fix script:
docker-compose exec web php /var/www/fix-db-config.php
If you see "Cannot add foreign key constraint" errors during initialization:
- This is handled automatically by disabling foreign key checks during import
- If it still fails, run manual initialization:
make db-init
- Or access the MySQL shell and import manually:
make mysql-shell # Then in MySQL: SET FOREIGN_KEY_CHECKS=0; SOURCE /var/www/install/_db/mysqli.schema.sql; SET FOREIGN_KEY_CHECKS=1;
The Dockerfile sets appropriate permissions, but if you encounter issues:
docker-compose exec web chown -R www-data:www-data /var/wwwIf port 80 or 8080 is already in use, modify the port mappings in docker-compose.yml:
ports:
- "8081:80" # Change 80 to 8081 or another available portIf you need to start completely fresh:
make rebuildThis will:
- Remove all containers and volumes
- Rebuild the images
- Start fresh with a new database
The application files are mounted as a volume, so changes to your local files will be reflected immediately in the container (except for configuration changes that might require a container restart).
To restart the web server after configuration changes:
docker-compose restart webThis is a deliberately vulnerable application for security training. DO NOT deploy this to a production environment or expose it to the internet.