PDZ domains are important scaffolding modules that typically bind to the C-termini of their interaction partners. Several structures of such complexes have been solved, revealing a conserved binding site in the PDZ domain and an extended conformation of the bound peptide. A compendium of information regarding PDZ complexes demonstrates that dissimilar C-terminal peptides bind to the same PDZ domain, and different PDZ domains can bind the same peptides. A detailed understanding of the PDZ-peptide recognition is needed to elucidate this complexity. To this end, we have designed a family of docking protocols for PDZ domains (termed PDZ-DocScheme) that is based on simulated annealing molecular dynamics and rotamer optimization, and is applicable to the docking of long peptides (20-40 rotatable bonds) to both known PDZ structures and to the more complicated problem of homology models of these domains. The resulting protocol reproduces the structures of PDZ complexes with peptides 4-8 amino acids long within 1-2 Å from the experimental structure when the docking is performed to the original structure. If the structure of the target PDZ domain is an apo structure or a homology model, the docking protocol yields structures within 3 Å in 9 out of 12 test cases. The automated docking procedure PDZ-DocScheme can serve in the generation of a structural context for validation of PDZ domain specificity from mutagenesis and ligand binding data.