  Let $D$ be a Jordan domain of unit capacity. We study the partition function
of a planar Coulomb gas in $D$ with a hard wall along $\eta = \partial D$,
\[Z_{n}(D) =\frac 1{n!}\int_{D^n}\prod_{1\le k < \ell \le n}|z_k-z_\ell|^{2}
\prod_{k=1}^n d^2z_k.\] We are interested in how the geometry of $\eta$ is
reflected in the large $n$ behavior of $Z_n(D)$. We prove that $\eta$ is a
Weil-Petersson quasicircle if and only if
  \[
  \log Z_n(D)= \log Z_n(\mathbb{D}) -I^L(\eta)/12 + o(1), \quad n\to \infty,
  \]
  where $I^L(\eta)$ is the Loewner energy of $\eta$, $\mathbb{D}$ is the unit
disc, and $\log Z_n(\mathbb{D}) = \log n!/\pi^n$. We next consider piecewise
analytic $\eta$ with $m$ corners of interior opening angles $\pi \alpha_p,
p=1,\ldots, m$. Our main result is the asymptotic formula
  \[
  \log Z_n(D)= \log Z_n(\mathbb{D}) - \frac 16\sum_{p=1}^m \left(\alpha_p+\frac
1{\alpha_p}-2 \right) \log n + o(\log n), \quad n\to \infty,
  \] which is consistent with physics predictions. The starting point of our
analysis is an exact expression for $\log Z_{n}(D)$ in terms of a Fredholm
determinant involving the truncated Grunsky operator for $D$. The proof of the
main result is based on careful asymptotic analysis of the Grunsky
coefficients. As further applications of our method we also study the Loewner
energy and the related Fekete-Pommerenke energy, a quantity appearing in the
analysis of Fekete points, for equipotentials approximating the boundary of a
domain with corners. We formulate several conjectures and open problems.
