Is the gluon also a repulsive force? 
In the picture of a proton we see 3 quarks, held together by gluons. But the two $u$ quarks repel each other , so the gluons act through the strong force, whereas the $u$ and $d$ quarks attract each other, if all this is correct, then what keeps them a part? can a gluon also act as a repulsive force?
EDIT: there is something that escapes me, if the answer is correct :"* at a certain distance the force becomes repulsive*". Presumably, the distance between U-U and U-D is the same, so why in one case it repels and in the other attracts?
 A: Lets start from experimental facts. The proton exists and is stable. This means that at the quantum level there must be one stable wave function a solution of the complicated potentials of both the electromagnetic and the strong force. The proton is even more complicated than your picture as there are innumerable quark-antiquark and gluon pairs in its makup.See this article:

The mathematical complication is modeled with lattice quantum field theory, with which the higher bound states of the nucleon have been successfully modeled, for example see the figures here.
My basic point is that the proton is a quantum bound state of its constituents, as are the higher mass states of the baryon octet and decuplet. The proton is stable because it is the lowest energy state.
A: Description of force inside the nucleons (between quarks):
The strong force is pretty weird, we can't even compute exact solutions for it in quantum field theory (that is the most accurate description for interactions or particles/fields).
So we compute it in limits, such as the limit when the distance becomes small or big, but we can't compute all the exact values as the distance increases and show it as a function (in the first image you can see an approximation of what data from the accelerators tells us, but mathematically can't be exactly computed).
What we found in 1973, was that the attractive colour force (strong force mediated by gluons) actually gets weaker as quarks get closer together. This is called asymptotic freedom (quarks tend to get free as we approach lower distance scales [higher energy scales]). Since quarks become non-interacting at short distances, there is no need for a force to keep them apart, you can see better this in the following image, where the colour charge can be interpreted as the strength of the force.

In the other limit case, we found that there is what we call confinement, which is that when we separate the quarks (higher scale distance/lower scale energies) the attractive colour force essentially approaches a high constant value, keeping them together or then at some higher distance the gluon force disappears because particle-antiparticle creation is possible for which one takes the previous position of our original now separated quark, and the other gets in a bound state with our separated particle :)

You can see now why they are called gluons, they don't let the quarks be alone, they are always glued to more quarks!
Description of force between nucleons (not between quarks):
Now we can say that there is a remanent of the interaction between quarks with gluons, that radiates outside the nucleon (proton or neutron), which then makes protons and neutrons interact, attracting them and binging them together in the nucleus. But this residual force keeps them at a distance, not like the electric attractive force, which always wants to make them closer and closer and closer.
It can be seen and understood way better if you see this graphic of the corresponding forces. Where you see that the residual strong force starts repulsive, and at a certain distance around the separation of nucleons, becomes attractive.
You can also see that the residual strong attractive force in its peak is way bigger than the repulsive electric one, which means that its effect dominates, fixing the particles at a concrete distance. Or in the case of the same electric charge particles, when the electric force tries to take them together too much, then the strong force becomes repulsive and again fixes them at concrete separation.

Edit: Extra images from Visualizations of Quantum Chromodynamics (hyperlink) 
Simulations of the "quantum soups", where you can see it is going to be more complicated than balls interacting:

Simulations of what is called the flux tubes showing the gluon field, formed between quarks in meson states (pair quark-antiquark) or nucleons (three quarks):

where you can see these flux tubes tend to minimize their length uniting the three quarks together in one "Mercedes" sign flux. (In these last simulations they have fixated the form and the positions of the quarks, where in reality, again they would be more complex soups oscilating).
