How do photons reach thermal equilibrium with the walls of the blackbody cavity? There's a lot that has been confusing to me about Planck's radiation law, and at this point I feel like I've got the hang of most of it. There is really only one last question that I can't resist asking, just to make sure I haven't misunderstood something.
How do the photons come into thermal equilibrium with the walls of the blackbody cavity if the walls are made of perfect conductors (an assumption being made in many articles on the subject)?
The reason we assume that the walls are made of conductors is to make sure that the electric and magnetic fields vanish at the boundary, which implies that the wavelengths need to perfectly fit within the walls of the container, such that the fields are zero there. But if the walls are made of perfect conductors, then won't the photons just reflect off of the surface (since conductors are good reflectors) without ever interchanging thermal energy with the walls? In that case, they would never come into equilibrium, and all of the calculations involving Boltzmann's distribution that is used in the derivation wouldn't work, since Boltzmann's distribution applies to small systems that are in thermal contact with a heat reservoir, and in this case I guess the photons are the small systems and the walls are meant to be the reservoirs.
 A: The walls of the cavity are not made of conductor, since in this case they would be reflecting, instead of absorbing all the radiation.
In statistical physics one usually neglects the interactions leading to the establishment of the equilibrium. For example, the Maxwell-Boltzmann distribution does not depend on the collisions between the atoms, which are responsible for establishment of the equilibrium. Using developer's language, this is not a bug, but a feature - the statistical mechanics is based on logical reasoning, which allows to obtain very general results without sinking in gory details.
If course, in reality there are processes that lead to the establishment of the thermal equilibrium. E.g., if we start with a gas of two-level atoms, with transition frequency $\omega$, and no radiation - we would expect, in the first approximation, that only the radiation modes of this frequency will come into equilibrium with atoms. For full equilibrium we need to account for higher order processes, such as, e.g., the Raman scattering. Thus, this may take longer for the Planck's distribution to establish, but it will eventually be achieved - we believe in this, as we believe in energy conservation.
Remark
As one can see from the answers here (and from a discussion around a concurrent question), some confusion results from different ways one can define the black body radiation (BBR):

*

*BBR is a photon gas in thermal equilibrium If the number of photons in mode $\mathbf{k},\lambda$ is described by canonical distribution,
$$
p(n_{\mathbf{k},\lambda})\propto e^{-\beta \hbar\omega_{\mathbf{k},\lambda}n_{\mathbf{k},\lambda}},
$$
Planck's formula readily follows. In this case the radiation does not necessarily have to be in a contact with a black body - the role of the body/material is to mediate the energy exchange between the photon modes, for the thermal equilibrium to establish. This is the point of view adopted above. A perfect metal reflects all the radiation, and cannot lead to thermodynamic equilibrium. On the other hand, a metal with finite conductivity can do so (although not very efficiently) - the filament of an incadescent lamp could be discussed in this context. Black body is defined here as a body that emits radiation that is already black.

*BBR is the radiation emitted by a black body Here one postulates the properties of a black body - an object in thermal equilibrium that absorbs all the radiation incident at it. One can then calculate the radiation emitted by this object, which will be described by Planck's formula. This approach was taken historically, and presented in most introductory QM books, which is why many people stick to it. It's advantage is that one does not really need a cavity - the radiation is already black, which is how one applies Planck's formula to the radiation emitted by stars and other thermal sources, which are clearly non-equilibrium situations. (The cavity does appear in this approach, as a way to model a black body.) As I pointed out above, a metal (even a metal with a finite conductivity) cannot serve as a black body, because it does not absorb all the radiation incident on it.

A: I think that there is one thing you forget. All standing waves, corresponding to different energy photons, can make transitions to lower energy states upon interacting with the boundary of the cave. Upon each interaction, the standing waves "loose" a photon to the walls. This continues until there is an equilibrium with the walls. There are as many photons coming in as going out in that case.
It seems counterintuitive that photons can be there where the field is zero but remember that the standing wave pattern is built up from waves emerging from the walls. Waves are constantly emerging and adjusting (to form a standing wave), in the process of which the value at the walls is not always zero. On the mean it is, but to exchange energy (photons) the field has to be non-zero continuously. It is  non-zero, but very close to zero. The waves are a kind of "fluctuating" standing waves in order to make energy transfer possible. This happens in the classical pisture as well as in the quantum picture.
A: Just because the electric field is zero at the boundary with a reflector does not mean that the electric field is not interacting with the medium beyond the boundary; quite the opposite. It requires the motion of charges in the reflective medium in order to setup the electric fields that cancel with any "incident" electric field at the boundary. https://physics.stackexchange.com/a/605418/43351 If the reflector was not absolutely perfect, and had a finite conductivity, there are thermal effects that could perturb the motion of free charges and result in a modification of the fields at the interface. Note, the fact that the walls are reflective does not preclude using them to produce blackbody radiation in a cavity because the light can undergo as many reflections as are required to be effectively absorbed.
However, if the walls really were perfectly reflective then I agree, it is hard to see how the radiation and walls could ever come into thermal equilibrium. However, that is not required to derive the Planck function, which simply assumes that thermal equilibrium has been achieved.
This is the wave picture. If you want to discuss photons, then of course the photons incident upon the walls are not necessarily the same photons that come back off the walls. Those photons are emitted by atoms within the walls, so clearly there are interactions going on and at equilibrium there are just as many photons emitted as absorbed.
A: At first, energy is transferred during reflection. For example, if you put mirror into space and enlight it, photons will kick it away, making solar sail.
At second, this is not used in Planck formula derivation. The "black body" is an amount of radiation itself, disregarding what is keeping this radiation in place. There can be not walls, but magic, which confine radiation inside.
The assumptions are:

*

*radiation is confined inside cavity


*somehow (doesn't matter how), waves can interchange energy


*the energy is quantized
That's all. Energy transfer to walls is not used.
In Einstein's derivation he used energy transfer between photons and atoms, but he didn't use mirror cavity.
A: The walls produce the photons, so they are in thermal equilibrium from the moment they are emitted.
