From d8841188279968207267559ad9585116f93a364b Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion)" Date: Thu, 13 Feb 2014 15:36:22 +0100 Subject: [PATCH] Add a 'make ssh' task for easily SSHing into the container --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7b98626..2c2d545 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ NAME = phusion/baseimage VERSION = 0.9.6 -.PHONY: all build test tag_latest release +.PHONY: all build test tag_latest release ssh all: build @@ -18,3 +18,11 @@ release: test tag_latest @if ! docker images phusion/baseimage | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi docker push $(NAME) @echo "*** Don't forget to create a tag. git tag rel-$(VERSION) && git push origin rel-$(VERSION)" + +ssh: + chmod 600 image/insecure_key.pub + @ID=$$(docker ps | grep -F "$(NAME):$(VERSION)" | awk '{ print $$1 }') && \ + if test "$$ID" = ""; then echo "Container is not running."; exit 1; fi && \ + IP=$$(docker inspect $$ID | grep IPAddr | sed 's/.*: "//; s/".*//') && \ + echo "SSHing into $$IP" && \ + ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i image/insecure_key root@$$IP