Skip to content

Commit a01ed1c

Browse files
authored
Add starting container for exec command if the container is not running. (#21)
* Add starting container for exec command if the container is not running. * Fix errata in exec alias.
1 parent a583269 commit a01ed1c

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.4
1+
0.1.5

cmd/ducker/ducker.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ func dockerExec(ctx *cli.Context) {
171171
execCmd := "docker exec -ti " + lastContainerID
172172
execCmd += " " + shellCmd
173173

174+
result := getTerminalCmdOut("docker", "ps -f id=" + lastContainerID)
175+
if !strings.Contains(result, lastContainerID) {
176+
fmt.Println("Last container " + lastContainerID + " is not running.")
177+
fmt.Println("Start container ...")
178+
getTerminalCmdOut("docker", "start " + lastContainerID)
179+
}
180+
174181
runTerminalCmdInShell(execCmd)
175182
}
176183

@@ -437,12 +444,12 @@ func main() {
437444
},
438445
{
439446
Name: "exec",
440-
Aliases: []string{"r"},
447+
Aliases: []string{"e"},
441448
Usage: "Executing the docker container",
442449
Flags: []cli.Flag{
443450
&cli.StringFlag{
444451
Name: "shell",
445-
Aliases: []string{"s"},
452+
Aliases: []string{"e"},
446453
Usage: "Shell type to run (bash, zsh)",
447454
Value: "zsh",
448455
DefaultText: "zsh",

install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ elif [ "$1" = "uninstall" ]; then
5252
exit 0
5353
fi
5454
else
55-
echo "Wrong command $0"
55+
echo "Wrong command $1"
5656
echo "Please use install.sh install or install.sh uninstall"
5757
exit 1
5858
fi

0 commit comments

Comments
 (0)