1
0
mirror of https://github.com/phusion/baseimage-docker.git synced 2026-03-26 04:18:46 +00:00

Allow 'make test' to work on macOS by publishing the SSH port and using that during tests, as the IP address cannot be directly reached on macOS docker

This commit is contained in:
Arnold Hendriks
2018-04-09 23:08:01 +02:00
parent 92a357a41f
commit 2f0e1ad0b8

View File

@@ -17,13 +17,13 @@ function cleanup()
PWD=`pwd` PWD=`pwd`
echo " --> Starting insecure container" echo " --> Starting insecure container"
ID=`docker run -d -v $PWD/test:/test $NAME:$VERSION /sbin/my_init --enable-insecure-key` ID=`docker run -d -p 22 -v $PWD/test:/test $NAME:$VERSION /sbin/my_init --enable-insecure-key`
sleep 1 sleep 1
echo " --> Obtaining IP" echo " --> Obtaining SSH port number"
IP=`docker inspect -f "{{ .NetworkSettings.IPAddress }}" "$ID"` SSHPORT=`docker inspect --format='{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' "$ID"`
if [[ "$IP" = "" ]]; then if [[ "$SSHPORT" = "" ]]; then
abort "Unable to obtain container IP" abort "Unable to obtain container SSH port number"
fi fi
trap cleanup EXIT trap cleanup EXIT
@@ -38,5 +38,5 @@ echo " --> Logging into container and running tests"
cp image/services/sshd/keys/insecure_key /tmp/insecure_key cp image/services/sshd/keys/insecure_key /tmp/insecure_key
chmod 600 /tmp/insecure_key chmod 600 /tmp/insecure_key
sleep 1 # Give container some more time to start up. sleep 1 # Give container some more time to start up.
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/insecure_key root@$IP \ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/insecure_key -p $SSHPORT root@127.0.0.1 \
/bin/bash /test/test.sh /bin/bash /test/test.sh