Skip to content

Commit 8e921d4

Browse files
committed
Merge pull request #64 from moul/fix-63
Support of custom entrypoint (fix #63)
2 parents 0cb4c70 + 0cc4060 commit 8e921d4

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ $ docker run --privileged -v /var/lib/docker:/var/lib/docker -it --rm -p 2222:22
161161

162162
### master (unreleased)
163163

164+
* Support of custom entrypoint ([#63](https://github.com/moul/ssh2docker/issues/63))
164165
* Support of public-key authentication ([#2](https://github.com/moul/ssh2docker/issues/2))
165166
* Handling custom environment variables, user and command in password script ([#57](https://github.com/moul/ssh2docker/issues/57))
166167
* Replacing "_" by "/" on default image name to handle ControlMaster on clients

client.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type ClientConfig struct {
3939
Command []string `json:"command",omitempty`
4040
User string `json:"user",omitempty`
4141
Keys []string `json:"keys",omitempty`
42+
EntryPoint string `json:"entrypoint",omitempty`
4243
}
4344

4445
// NewClient initializes a new client
@@ -165,7 +166,11 @@ func (c *Client) HandleChannelRequests(channel ssh.Channel, requests <-chan *ssh
165166
// Opening Docker process
166167
if existingContainer != "" {
167168
// Attaching to an existing container
168-
args := []string{"exec", "-it", existingContainer, c.Server.DefaultShell}
169+
shell := c.Server.DefaultShell
170+
if c.Config.EntryPoint != "" {
171+
shell = c.Config.EntryPoint
172+
}
173+
args := []string{"exec", "-it", existingContainer, shell}
169174
logrus.Debugf("Executing 'docker %s'", strings.Join(args, " "))
170175
cmd = exec.Command("docker", args...)
171176
cmd.Env = c.Config.Env.List()
@@ -177,6 +182,9 @@ func (c *Client) HandleChannelRequests(channel ssh.Channel, requests <-chan *ssh
177182
if c.Config.User != "" {
178183
args = append(args, "-u", c.Config.User)
179184
}
185+
if c.Config.EntryPoint != "" {
186+
args = append(args, "--entrypoint", c.Config.EntryPoint)
187+
}
180188
args = append(args, c.Config.ImageName)
181189
if c.Config.Command != nil {
182190
args = append(args, c.Config.Command...)

0 commit comments

Comments
 (0)