Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func StartCommand() cli.Command {
Value: 8080,
Usage: "Specify port number to bind to on the host.",
},
cli.StringFlag{
Name: "iofs-dir",
Usage: "--iofs-dir to specify a directory or container engine volume for Fn Server to create unix socket file for cross container communication.\n" +
"By default, container named volume is used: \"fnserversocket\"",
},
},
}
}
Expand All @@ -75,10 +80,24 @@ func start(c *cli.Context) error {
fnDir = filepath.Join(home, ".fn")
}

// User could override iofs directory. The iofs path is used by Fn Server to create unix socket file
// for the communication between Fn Server and Fn Containers.
// If user is using Podman or Rancher desktop where the socket file could not be created under HOME directory
// (see: https://github.com/fnproject/fn/issues/1577#issuecomment-1297736260), user could provide a container
// named volume to work around.
// On Windows docker desktop, if we use OS directory as iofs path, we also observed that the fsnotify did not
// notify fnserver container when the socket file was created. However, named volume worked well.
// As a result, we decided to use named volume as default as it works in all cases.
// The named volume will be created automatically if it is not in the host machine.
iofsDir := "fnserversocket"
if c.String("iofs-dir") != "" {
iofsDir = c.String("iofs-dir")
}

args := []string{"run", "--rm", "-i",
"--name", "fnserver",
"-v", fmt.Sprintf("%s/iofs:/iofs", fnDir),
"-e", fmt.Sprintf("FN_IOFS_DOCKER_PATH=%s/iofs", fnDir),
"-v", fmt.Sprintf("%s:/iofs:Z", iofsDir),
"-e", fmt.Sprintf("FN_IOFS_DOCKER_PATH=%s", iofsDir),
"-e", "FN_IOFS_PATH=/iofs",
"-v", fmt.Sprintf("%s/data:/app/data", fnDir),
"-v", "/var/run/docker.sock:/var/run/docker.sock",
Expand Down