Skip to main content

Overview

This page covers issues specific to running DVWA in Docker containers, including port conflicts, log access, and MariaDB memory issues.

Prerequisites

Before troubleshooting, ensure you have Docker and Docker Compose properly installed:
docker version
docker compose version
```text

You should see version information in the output. For example:

```text
>>> docker version
Client:
 [...]
 Version:           23.0.5
 [...]

Server: Docker Desktop 4.19.0 (106363)
 Engine:
  [...]
  Version:          23.0.5
  [...]

>>> docker compose version
Docker Compose version v2.17.3

Common Docker Issues

Using Docker Desktop (GUI)

If you are using Docker Desktop, logs can be accessed from the graphical application. Some minor details may change with newer versions, but the access method should be the same.
  1. Open Docker Desktop
  2. Navigate to the Containers section
  3. Find the DVWA containers
  4. Click on the container to view its logs

Using Terminal

Logs can also be accessed from the terminal.Step 1: Open a terminal and change its working directory to DVWAStep 2: Show the merged logs
docker compose logs
```bash

**Export logs to a file:**

In case you want to export the logs to a file, e.g. `dvwa.log`:

```bash
docker compose logs > dvwa.log

Why Not Port 80 by Default?

DVWA uses port 4280 by default instead of port 80 for a few reasons:
  • Some users might already be running something on port 80
  • Some users might be using a rootless container engine (like Podman), and 80 is a privileged port (< 1024). Additional configuration (e.g. setting net.ipv4.ip_unprivileged_port_start) is required
For running DVWA in containers, the web server listens on port 4280 instead of the usual port 80.

Changing the Port

You can expose DVWA on a different port by changing the port binding in the compose.yml file.Example: Change from port 4280 to port 8806Before:
ports:
  - 127.0.0.1:4280:80
```text

**After:**
```yml
ports:
  - 127.0.0.1:8806:80
DVWA is now accessible at http://localhost:8806.

Network Access Warning

In cases where you want DVWA to be accessible on your local network (e.g. for a workshop), you can remove the 127.0.0.1: from the port mapping. This way it will listen on all available devices.The safe default should always be to only listen on your local loopback device. After all, it is a damn vulnerable web application, running on your machine.
Example for network access:
ports:
  - 4280:80
```sql

Or replace `127.0.0.1` with your LAN IP address.
</Accordion>

<Accordion title="DVWA auto-starts when Docker runs">
### The Behavior

The included `compose.yml` file automatically runs DVWA and its database when Docker starts.

### Disable Auto-Start Permanently

To disable this, you can delete or comment out the `restart: unless-stopped` lines in the `compose.yml` file.

**Example:**
```yml
# restart: unless-stopped

Disable Auto-Start Temporarily

If you want to disable this behavior temporarily:Option 1: Using Docker Compose
docker compose stop
```bash

**Option 2: Using Docker Desktop**
1. Find `dvwa` in the containers list
2. Click Stop

**Option 3: Remove containers**
```bash
docker compose down
docker compose down will delete the containers, while docker compose stop will just stop them.

Error Message

If you see the following error in the Docker logs while trying to start MariaDB:
    [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.15+maria~ubu2204 started.
    [Warn] [Entrypoint]: /sys/fs/cgroup///memory.pressure not writable, functionality unavailable to MariaDB

The Problem

This is likely due to the host machine not having enough memory.

Solutions

Solution 1: Increase Memory (Recommended)If you are using this in a hosted environment, the best solution is to step up a machine size to get more memory and try again.Solution 2: Add Volume MappingYou might also need to add the following line to the volumes section of your compose.yml file:
- /sys/fs/cgroup/memory.pressure:/sys/fs/cgroup/memory.pressure
```text

**Complete example:**

Doing that would change the volumes section of a default config file to the following:

```yml
volumes:
  - dvwa:/var/lib/mysql
  - /sys/fs/cgroup/memory.pressure:/sys/fs/cgroup/memory.pressure
For more information on why this works, see this issue.

Building from Local Changes

If you made local changes and want to build the project from local:Step 1: Go to compose.yml and change:
pull_policy: always
```text

To:
```yml
pull_policy: build
Step 2: Run:
docker compose up -d
```bash

This should trigger Docker to build an image from local regardless of what is available in the registry.

See also: [`pull_policy` documentation](https://github.com/compose-spec/compose-spec/blob/master/05-services.md#pull_policy).

### Serving Local Files (Development)

If you're making local changes and don't want to rebuild the project for every change:

**Step 1:** Go to `compose.yml` and uncomment:
```yml
# volumes:
#   - ./:/var/www/html
Step 2: Copy the default config file:
cp config/config.inc.php.dist config/config.inc.php
```bash

**Step 3:** Start the containers:
```bash
docker compose up -d
Changes to local files will now reflect on the container.

Docker Support

We provide support for the latest Docker release. If you are using Linux and the Docker package that came with your package manager, it will probably work too, but support will only be best-effort.

Upgrading Docker

Upgrading Docker from the package manager version to upstream requires that you uninstall the old versions. See Docker’s manuals for: Your Docker data (containers, images, volumes, etc.) should not be affected, but if you do run into a problem:

Getting Started with Docker

DVWA is available as a pre-built Docker image. For more information, you can browse the prebuilt Docker images. To get started:
  1. Clone or download the DVWA repository
  2. Open a terminal and change to the DVWA directory
  3. Run:
    docker compose up -d
    

DVWA is now available at `http://localhost:4280`.

Build docs developers (and LLMs) love