Graph clustering, which aims to partition a set of graphs into groups with similar structures, is a fundamental task in data analysis. With the great advances made by deep learning, deep graph clustering methods have achieved success. However, these methods have two limitations: (1) they learn graph embeddings by a neural language model that fails to effectively express graph properties, and (2) they treat embedding learning and clustering as two isolated processes, so the learned embeddings are unsuitable for the subsequent clustering. To overcome these limitations, we propose a novel capsule-based graph clustering (CGC) algorithm to cluster graphs. First, we construct a graph clustering capsule network (GCCN) that introduces capsules to capture graph properties. Second, we design an iterative optimization strategy to alternately update the GCCN parameters and clustering assignment parameters. This strategy leads GCCN to learn cluster-oriented graph embeddings. Experimental results show that our algorithm achieves performance superior to that of existing graph clustering algorithms in terms of three standard evaluation metrics: ACC, NMI, and ARI. Moreover, we use visualization results to analyze the effectiveness of the capsules and demonstrate that GCCN can learn cluster-oriented embeddings.