Coke is pronounced /kəʊk/ in British English and /koʊk/ in American English. Cock is pronounced /kɒk/ in British English and /kɑk/ in American English.
As you can see, it is the vowel sounds that are different. The two sounds are distinguished in two ways: (1) by one being a diphthong and the other being a monophthong, (the vowel sound changes quality in a diphthong and remains stable in a monophthong), and (2) the position of the tongue is different. The “long O” sound of Coke is a diphthong, whereas the “short O” sound of cock is a monophthong, and it is pronounced with the tongue in a lower position. Here is a vowel diagram for British English:
As you can see the vowel sound of Coke starts with the tongue in the position for /ə/, which is in a middle neutral position, and it moves up and slightly back to the position for /ʊ/. The vowel sound of cock, on the other hand, is pronounced with the tongue very low and very far back in the mouth, and it doesn’t move during the production of the sound. The differences in American English are similar.
Edit: @serg555 if you are notHere is a nativepage discussing all the pairs of words in English speaker, I might be able to explain howthat differ only by these vowel sounds relate to sounds from your native language, if you let us know what your native languagewhich suggests that this sound pair is a frequent difficulty for non-native speakers of English. I would suggest looking up those word pairs in an online dictionary, like Merriam-Webster and listening carefully to the recordings for each pair of words to hear the differences between them.