An Anderson impurity in a Hubbard model on chains with finite length is studied using the density-matrix renormalization group (DMRG) technique. In the first place, we analyzed how the reduction of electron density from half-filling to quarter-filling affects the Kondo resonance in the limit of Hubbard repulsion U=0. In general, a weak dependence with the electron density was found for the local density of states (LDOS) at the impurity except when the impurity, at half-filling, is close to a mixed valence regime. Next, in the central part of this paper, we studied the effects of finite Hubbard interaction on the chain at quarter-filling. Our main result is that this interaction drives the impurity into a more defined Kondo regime although accompanied in most cases by a reduction of the spectral weight of the impurity LDOS. Again, for the impurity in the mixed valence regime, we observed an interesting nonmonotonic behavior. We also concluded that the conductance, computed for a small finite bias applied to the leads, follows the behavior of the impurity LDOS, as in the case of non-interacting chains. Finally, we analyzed how the Hubbard interaction and the finite chain length affect the spin compensation cloud both at zero and at finite temperature, in this case using quantum Monte Carlo techniques.