Waiting for SSH service
on Test Kitchen with the Docker driver
Although the Docker driver is no longer included by default in the Chef Workstation, with kitchen-dokken being recommended now, you may still want to use it.
I was trying to run one of my older cookbooks, which uses it for integration tests, and found that my container was just timing out trying to connect:
Waiting for SSH service on localhost:49156, retrying in 3 seconds
Waiting for SSH service on localhost:49156, retrying in 3 seconds
Waiting for SSH service on localhost:49156, retrying in 3 seconds
This is odd, because I could see the container running, but nothing was happening with it, so there shouldn't have been a timeout.
When running Kitchen with debug logs, I could see Connection reset by peer
, which was increasingly odd:
D, [2021-04-07T13:46:32.165084 #122004] DEBUG -- default-debian: [SSH] connection failed (#<Errno::ECONNRESET: Connection reset by peer>)
I, [2021-04-07T13:46:32.165222 #122004] INFO -- default-debian: Waiting for SSH service on localhost:49156, retrying in 3 seconds
It turns out that I was missing the transport
configuration in my kitchen.yml
:
transport:
name: docker
Once I'd added this, the connection worked straight away, and my tests ran successfully.