If you are one of those people who love having a dog along on your outdoor activities, this post may be useful to you, especially if you bike on dirt/gravel/two-track roads. Most of this would also apply to riding on residential streets or off-street recreational trails.
You could consider one of the products available these days. Do a search using words like "dog running with bicycle" on You Tube. But it is hard to make such products fit a modern mountain bike, with a seat-dropper-post and through-axles. Hence this post.
Dogs do become trained over time to run alongside a bike without getting into trouble. This post is meant for a younger dog who still needs to get used to the idea.
Always attach the dog on the right side (starboard) of the bike. Keep the leash short -- which is a bit counter-intuitive. Always attach the leash to a halter on the dog, not to a collar.
If the dog was used to the idea, you could put a carabiner on the end of a standard 5' or 6' dog leash, and snap it onto your waistbelt. Then the dog would run alongside on the right, that is, perpendicular to your bike and body. The leash is long enough to reach the right wheel rut, while your bike would be in the left wheel rut.
But a younger untrained dog will lunge forward. The angle of the leash will then pull the dog into your front wheel.
If a squirrel runs from right to left, the dog might try to run across your front wheel. You could both be hurt. Hence the standoff extension.
She is learning.