Skip to content

Commit

Permalink
Merge pull request #64 from moul/fix-63
Browse files Browse the repository at this point in the history
Support of custom entrypoint (fix #63)
  • Loading branch information
moul committed Oct 19, 2015
2 parents 0cb4c70 + 0cc4060 commit 8e921d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion client.go
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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...)
Expand Down

0 comments on commit 8e921d4

Please sign in to comment.