Specify HostIP in driver attributes - Waiting for SSH service on localhost:32769
I run the KitchenCI using kitchen-docker in the Docker container (Drone.io). I expose the Drone docker sock to the inner instance that kitchenCI use to spin it's own CI containers. It works, however once the container is build kitchen fails to connect the host on exported port.
[Host: Docker:
[Drone.io],
[ inner "build" container created by Drone, where Kithen CI starts it's containers],
[ kitchen containers]
]
on host:
root@drone:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b0bb0703ebd 9daa5d4067e3 "/usr/sbin/sshd -D -o" 14 minutes ago Up 14 minutes 0.0.0.0:32769->22/tcp stoic_ramanujan
4c2f3655fb9c 57400823a8c3 "/usr/sbin/sshd -D -o" 15 minutes ago Up 15 minutes 0.0.0.0:32768->22/tcp focused_bell
in the innner container:
...
...
Step 17 : RUN chown kitchen /home/kitchen/.ssh/authorized_keys
---> Running in 9084358f89e6
---> 7120018c41c2
Removing intermediate container 9084358f89e6
Step 18 : RUN chmod 0600 /home/kitchen/.ssh/authorized_keys
---> Running in 8763c914ba43
---> 9daa5d4067e3
Removing intermediate container 8763c914ba43
Successfully built 9daa5d4067e3
3b0bb0703ebd454e30973808d3aed74429f2b1c164feb0495c664d9aa1b00e18
0.0.0.0:32769
Waiting for SSH service on localhost:32769, retrying in 3 seconds
Waiting for SSH service on localhost:32769, retrying in 3 seconds
Waiting for SSH service on localhost:32769, retrying in 3 seconds
...
...
is there a configuration attribute that would allow to specify HostIP that kitchen should use to connect host? so instead of localhost use IP or hostname of the external host?
Obiously not:
https://github.com/portertech/kitchen-docker/blob/master/lib/kitchen/driver/docker.rb#L106
so can we make that 'localhost' an driver attribute?
What I'm doing to work around this issue is setting 'localhost' to the IP that actually has the port bound to it. For me the default gateway of my container is the IP of my docker host. So I'm doing something like:
# Fake 'localhost' to go back to docker host
sed -e '/localhost/d' /etc/hosts > /var/tmp/hosts.new
cp /var/tmp/hosts.new /etc/hosts
echo "$(ip route | grep default | awk '{print $3}') localhost" >> /etc/hosts
I've encountered the same issue when running build with a docker gitlab runner, any hint to solve this?