services: git: ports: - 2222:22
But I kept getting an error message when trying to start the instance:
Cannot create container for service git: invalid port specification: "133342"
What the heck, where did that weird number come from ?!
It turns out YAML 1.1 supports so called "base 60 float" useful for time calculation. So 2222:22 is interpreted as 2222*60+22 which is 133342. ta-dah! It is not a problem if the parts contain numbers bigger than 60, e.g. 3306:3306, or 8080:80, so this problem does not always occur, making it covert.
So quote your ports!
services: git: ports: - "2222:22"