Skip to content

Commit

Permalink
Add starting container for exec command if the container is not runni…
Browse files Browse the repository at this point in the history
…ng. (#21)

* Add starting container for exec command if the container is not running.

* Fix errata in exec alias.
  • Loading branch information
JeiKeiLim authored Jun 5, 2023
1 parent a583269 commit a01ed1c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.4
0.1.5
11 changes: 9 additions & 2 deletions cmd/ducker/ducker.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ func dockerExec(ctx *cli.Context) {
execCmd := "docker exec -ti " + lastContainerID
execCmd += " " + shellCmd

result := getTerminalCmdOut("docker", "ps -f id=" + lastContainerID)
if !strings.Contains(result, lastContainerID) {
fmt.Println("Last container " + lastContainerID + " is not running.")
fmt.Println("Start container ...")
getTerminalCmdOut("docker", "start " + lastContainerID)
}

runTerminalCmdInShell(execCmd)
}

Expand Down Expand Up @@ -437,12 +444,12 @@ func main() {
},
{
Name: "exec",
Aliases: []string{"r"},
Aliases: []string{"e"},
Usage: "Executing the docker container",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "shell",
Aliases: []string{"s"},
Aliases: []string{"e"},
Usage: "Shell type to run (bash, zsh)",
Value: "zsh",
DefaultText: "zsh",
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ elif [ "$1" = "uninstall" ]; then
exit 0
fi
else
echo "Wrong command $0"
echo "Wrong command $1"
echo "Please use install.sh install or install.sh uninstall"
exit 1
fi
Expand Down

0 comments on commit a01ed1c

Please sign in to comment.