From 0cc40602ab4dea39968cdc4fc3583a0f6b1af65f Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 20 Oct 2015 01:48:55 +0200 Subject: [PATCH] Support of custom entrypoint (fix #63) --- README.md | 1 + client.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f105026..fc18c8c 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ $ docker run --privileged -v /var/lib/docker:/var/lib/docker -it --rm -p 2222:22 ### master (unreleased) +* Support of custom entrypoint ([#63](https://github.com/moul/ssh2docker/issues/63)) * Support of public-key authentication ([#2](https://github.com/moul/ssh2docker/issues/2)) * Handling custom environment variables, user and command in password script ([#57](https://github.com/moul/ssh2docker/issues/57)) * Replacing "_" by "/" on default image name to handle ControlMaster on clients diff --git a/client.go b/client.go index fa81c27..bf70e89 100644 --- a/client.go +++ b/client.go @@ -39,6 +39,7 @@ type ClientConfig struct { Command []string `json:"command",omitempty` User string `json:"user",omitempty` Keys []string `json:"keys",omitempty` + EntryPoint string `json:"entrypoint",omitempty` } // NewClient initializes a new client @@ -165,7 +166,11 @@ func (c *Client) HandleChannelRequests(channel ssh.Channel, requests <-chan *ssh // Opening Docker process if existingContainer != "" { // Attaching to an existing container - args := []string{"exec", "-it", existingContainer, c.Server.DefaultShell} + shell := c.Server.DefaultShell + if c.Config.EntryPoint != "" { + shell = c.Config.EntryPoint + } + args := []string{"exec", "-it", existingContainer, shell} logrus.Debugf("Executing 'docker %s'", strings.Join(args, " ")) cmd = exec.Command("docker", args...) cmd.Env = c.Config.Env.List() @@ -177,6 +182,9 @@ func (c *Client) HandleChannelRequests(channel ssh.Channel, requests <-chan *ssh if c.Config.User != "" { args = append(args, "-u", c.Config.User) } + if c.Config.EntryPoint != "" { + args = append(args, "--entrypoint", c.Config.EntryPoint) + } args = append(args, c.Config.ImageName) if c.Config.Command != nil { args = append(args, c.Config.Command...)