A metric space is compact exactly when every continuous function is bounded. For the converse, a noncompact metric space contains a closed discrete sequence; the unbounded function assigning its th point the value extends to by the Tietze extension theorem.
Codex Wiki