What is the meaning of Romans 6:17?

17 But God be thanked, that ye were the servants of sin, but ye have obeyed from the heart that form of doctrine which was delivered you. (Romans 6:17 KJV)

William Burkitt’s Commentary

We must understand these words; as if Apostle Paul blessed God because they were once slaves to sin and Satan: but thanks God, that the time of that bondage was past and over; as if he had said, “God be thanked, that though formerly you were the servants of sin, yet, since your conversion, you are become obedient to the precepts of Christianity, having obeyed from the heart, that form of doctrine, or (according to the original) being cast into the mould of that doctrine, which was delivered to you.
Learn hence, That to be turned from the service of sin to the sincere obedience of the gospel is a mercy that we can never be sufficiently sensibly of and bless God for. God be thanked, that although you were the servants of sin, you are no longer so.
Learn, 2. That the doctrine of the gospel has a divine efficacy attending and accompanying it on the hearts of believers; it has a transforming power to change and fashion men’s minds into the likeness of it, as the mould does the metal that is cast into it: The doctrine of the gospel is the mould, and the heart is the metal, which, when melted and cast into the mould, receives its form and figure.
Oh, happy they! who, having all their days sat under the dispensation of the gospel, are able at last to say, We are transformed and changed into the same image, from glory to glory, by the Spirit of the Lord.