Modern rear lights use AA batteries that last very long, but still need to be replaced once in a while. Replacing is simple, but take time.
Here is a simple circuit that lets you use your dynamo of your bicycle to power the rear light.
Left of the 5V regulator (7805) is a circuit that is called a charge pump. The charge pump doubles the voltage of the dynamo and limits the input current. Limiting ensures there is enough power available for you front light.
Right of the regulator you can see a supercapacitor with 1 Farad capacity. Charging the capacitor from empty takes just a few seconds of cycling before the LED starts to light up.
When you stop cycling, the LED keeps shining for about half an hour. This is allows you to be seen by other vehicles on the road at a crossing.
The components can be mounted dead-bug style in an empty bicycle LED light.
I used the existing rear light of my bike. I gutted it first keeping only the existing red LED.
Once done soldering your new light you can mount it and connect the cables to the dynamo.