Can't execute Shell Command "Docker"

I am experimenting with docker on my Synology NAS. And… I got it working… yay!

But since I want to automate the process of building the Container, I need to call the docker command using a shell control.
But when I execute the series of commands, it returns an error:

bash: docker: command not found

What am I doing wrong?

Are you giving it the full path in the call?

full/path/to/docker?

1 Like

I thought of that, too.
But since I can call Docker from any folder in the Terminal, I figured that it should work from shell as well.

nope you need a full path in a shell

  • or manually set the PATH environment variable (in interactive mode)

You likely have init script that set $PATH in Terminal that are not being set through a Shell. There is a switch to login (I think) that will force those scripts to be run, but I typically use that just to locate a tool, then use its full path thereafter.

I’d have to go look up that code.

1 Like

The command which in Terminal should give you the full path to Docker.
which docker

2 Likes

This is the code we use to locate a particular tool. You can adapt it as needed.

Private Function FindCliApp(cli As String) As FolderItem
  dim f as FolderItem
  
  #if TargetMacOS or TargetLinux then
    dim sh as new shell
    sh.Execute "/bin/bash -lc " + ShellQuote("which " + cli.Trim)
    if sh.ErrorCode = 0 then
      dim path as string = sh.Result
      path = ReplaceLineEndings(path, EndOfLine).Trim
      path = path.NthField(EndOfLine, path.CountFields(EndOfLine))
      f = new FolderItem(path, FolderItem.PathTypeNative)
    end if
  #endif
  
  return f
  
End Function
3 Likes