@@ -19,6 +19,7 @@ package cmd
1919import (
2020 "fmt"
2121 "net/url"
22+ "runtime"
2223 "strings"
2324
2425 "github.com/cortexlabs/cortex/pkg/lib/errors"
@@ -43,7 +44,8 @@ func getCloudFormationURL(clusterName, region string) string {
4344const (
4445 ErrCLINotConfigured = "cli.cli_not_configured"
4546 ErrCortexYAMLNotFound = "cli.cortex_yaml_not_found"
46- ErrDockerDaemon = "cli.docker_daemon"
47+ ErrConnectToDockerDaemon = "cli.connect_to_docker_daemon"
48+ ErrDockerPermissions = "cli.docker_permissions"
4749 ErrDockerCtrlC = "cli.docker_ctrl_c"
4850 ErrAPINotReady = "cli.api_not_ready"
4951 ErrFailedToConnectOperator = "cli.failed_to_connect_operator"
@@ -88,10 +90,29 @@ func ErrorCortexYAMLNotFound() error {
8890 })
8991}
9092
91- func ErrorDockerDaemon () error {
93+ func ErrorConnectToDockerDaemon () error {
94+ installMsg := "install it by following the instructions for your operating system: https://docs.docker.com/install"
95+ if strings .HasPrefix (runtime .GOOS , "darwin" ) {
96+ installMsg = "install it here: https://docs.docker.com/docker-for-mac/install"
97+ }
98+
99+ return errors .WithStack (& errors.Error {
100+ Kind : ErrConnectToDockerDaemon ,
101+ Message : fmt .Sprintf ("unable to connect to the Docker daemon\n \n please confirm Docker is running, or if Docker is not installed, %s" , installMsg ),
102+ })
103+ }
104+
105+ func ErrorDockerPermissions (err error ) error {
106+ errStr := errors .Message (err )
107+
108+ var groupAddStr string
109+ if strings .HasPrefix (runtime .GOOS , "linux" ) {
110+ groupAddStr = " (e.g. by running `sudo groupadd docker && sudo gpasswd -a $USER docker`)"
111+ }
112+
92113 return errors .WithStack (& errors.Error {
93- Kind : ErrDockerDaemon ,
94- Message : "unable to connect to the Docker daemon, please confirm Docker is running" ,
114+ Kind : ErrDockerPermissions ,
115+ Message : errStr + " \n \n you can re-run this command with `sudo`, or grant your current user access to docker" + groupAddStr ,
95116 })
96117}
97118
0 commit comments