have no choice but~
Expresses that there is no other option but to do something; often conveys resignation.
When you feel you have no alternative, use しかない. It's like saying 'there's no choice but to...' in English. You attach it to the plain form of a verb, which is the form you find in the dictionary. This pattern is common in spoken and written Japanese and is often used when you reluctantly accept a situation.
For example, if the last train has left, you might say 歩いて帰るしかない, meaning you have no choice but to walk home. It can also be used with nouns to mean 'there is nothing but X' or 'only X exists', but the most common usage is with verbs.
Note that しかない is different from ばかりいる or だけ, which simply indicate 'only'. しかない with a verb carries a sense of obligation or resignation, especially when you'd prefer a different outcome.