Dopamine Motivates Through Craving and Reward
Although dopamine is released when you experience pleasure or reward, it is not the primary driver of pleasure. That is a different pathway. Instead, dopamine is better known as the molecule of pursuit. It is not only released when you experience pleasure or reward, but when you anticipate it, just prior to a reward being given. This increases motivation to act in pursuit of something. Dopamine is therefore primarily responsible for reinforcing behaviour by motivating through craving, desire, and reward. This is how habits are formed: they are dopamine driven feedback loops.
The beauty of this system is that it is very general and non-specific. You can reframe things in your mind such that the dopamine system reinforces behaviour that you want. Reframing something changes what you see and your response to it. For example, reframing how you view failure or stress from something that you want to avoid, to something that is a precursor to success, can result in a craving or desire that drives you forward towards reward.
Deliberate effort is required to reframe a desired behaviour in a way so that your dopamine system reinforces it. It is best to start with small steps in order to build and maintain momentum, which is very important. The small step towards the right direction needs to be what provides the reward.
References
Atomic Habits by James Clear
Controlling Your Dopamine For Motivation, Focus & Satisfaction - Huberman Lab Podcast 39
How to Increase Motivation & Drive
The Power of Habit by Charles Duhigg