Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -1,11 +1,5 @@ |
| 1 | 1 |
package main |
| 2 | 2 |
|
| 3 |
-import ( |
|
| 4 |
- "os" |
|
| 5 |
- "os/exec" |
|
| 6 |
- "syscall" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 | 3 |
const daemonBinary = "dockerd" |
| 10 | 4 |
|
| 11 | 5 |
// DaemonProxy acts as a cli.Handler to proxy calls to the daemon binary |
| ... | ... |
@@ -15,29 +9,3 @@ type DaemonProxy struct{}
|
| 15 | 15 |
func NewDaemonProxy() DaemonProxy {
|
| 16 | 16 |
return DaemonProxy{}
|
| 17 | 17 |
} |
| 18 |
- |
|
| 19 |
-// CmdDaemon execs dockerd with the same flags |
|
| 20 |
-// TODO: add a deprecation warning? |
|
| 21 |
-func (p DaemonProxy) CmdDaemon(args ...string) error {
|
|
| 22 |
- args = stripDaemonArg(os.Args[1:]) |
|
| 23 |
- |
|
| 24 |
- binaryAbsPath, err := exec.LookPath(daemonBinary) |
|
| 25 |
- if err != nil {
|
|
| 26 |
- return err |
|
| 27 |
- } |
|
| 28 |
- |
|
| 29 |
- return syscall.Exec( |
|
| 30 |
- binaryAbsPath, |
|
| 31 |
- append([]string{daemonBinary}, args...),
|
|
| 32 |
- os.Environ()) |
|
| 33 |
-} |
|
| 34 |
- |
|
| 35 |
-// stripDaemonArg removes the `daemon` argument from the list |
|
| 36 |
-func stripDaemonArg(args []string) []string {
|
|
| 37 |
- for i, arg := range args {
|
|
| 38 |
- if arg == "daemon" {
|
|
| 39 |
- return append(args[:i], args[i+1:]...) |
|
| 40 |
- } |
|
| 41 |
- } |
|
| 42 |
- return args |
|
| 43 |
-} |
| 44 | 18 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,37 @@ |
| 0 |
+// +build !windows |
|
| 1 |
+ |
|
| 2 |
+package main |
|
| 3 |
+ |
|
| 4 |
+import ( |
|
| 5 |
+ "os" |
|
| 6 |
+ "os/exec" |
|
| 7 |
+ "syscall" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+// CmdDaemon execs dockerd with the same flags |
|
| 11 |
+// TODO: add a deprecation warning? |
|
| 12 |
+func (p DaemonProxy) CmdDaemon(args ...string) error {
|
|
| 13 |
+ // Use os.Args[1:] so that "global" args are passed to dockerd |
|
| 14 |
+ args = stripDaemonArg(os.Args[1:]) |
|
| 15 |
+ |
|
| 16 |
+ // TODO: check dirname args[0] first |
|
| 17 |
+ binaryAbsPath, err := exec.LookPath(daemonBinary) |
|
| 18 |
+ if err != nil {
|
|
| 19 |
+ return err |
|
| 20 |
+ } |
|
| 21 |
+ |
|
| 22 |
+ return syscall.Exec( |
|
| 23 |
+ binaryAbsPath, |
|
| 24 |
+ append([]string{daemonBinary}, args...),
|
|
| 25 |
+ os.Environ()) |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+// stripDaemonArg removes the `daemon` argument from the list |
|
| 29 |
+func stripDaemonArg(args []string) []string {
|
|
| 30 |
+ for i, arg := range args {
|
|
| 31 |
+ if arg == "daemon" {
|
|
| 32 |
+ return append(args[:i], args[i+1:]...) |
|
| 33 |
+ } |
|
| 34 |
+ } |
|
| 35 |
+ return args |
|
| 36 |
+} |
| 0 | 37 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,11 @@ |
| 0 |
+package main |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "fmt" |
|
| 4 |
+) |
|
| 5 |
+ |
|
| 6 |
+// CmdDaemon reports on an error on windows, because there is no exec |
|
| 7 |
+func (p DaemonProxy) CmdDaemon(args ...string) error {
|
|
| 8 |
+ return fmt.Errorf( |
|
| 9 |
+ "`docker daemon` does not exist on windows. Please run `dockerd` directly") |
|
| 10 |
+} |
| 0 | 11 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+package main |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "strings" |
|
| 4 |
+ "testing" |
|
| 5 |
+) |
|
| 6 |
+ |
|
| 7 |
+func TestCmdDaemon(t *testing.T) {
|
|
| 8 |
+ proxy := NewDaemonProxy() |
|
| 9 |
+ err := proxy.CmdDaemon("--help")
|
|
| 10 |
+ if err == nil {
|
|
| 11 |
+ t.Fatal("Expected CmdDaemon to fail in Windows.")
|
|
| 12 |
+ } |
|
| 13 |
+ |
|
| 14 |
+ if !strings.Contains(err.Error(), "Please run `dockerd`") {
|
|
| 15 |
+ t.Fatalf("Expected an error about running dockerd, got %s", err)
|
|
| 16 |
+ } |
|
| 17 |
+} |
| ... | ... |
@@ -9,16 +9,11 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/cli" |
| 10 | 10 |
"github.com/docker/docker/dockerversion" |
| 11 | 11 |
flag "github.com/docker/docker/pkg/mflag" |
| 12 |
- "github.com/docker/docker/pkg/reexec" |
|
| 13 | 12 |
"github.com/docker/docker/pkg/term" |
| 14 | 13 |
"github.com/docker/docker/utils" |
| 15 | 14 |
) |
| 16 | 15 |
|
| 17 | 16 |
func main() {
|
| 18 |
- if reexec.Init() {
|
|
| 19 |
- return |
|
| 20 |
- } |
|
| 21 |
- |
|
| 22 | 17 |
// Set terminal emulation based on platform as required. |
| 23 | 18 |
stdin, stdout, stderr := term.StdStreams() |
| 24 | 19 |
|
| ... | ... |
@@ -188,7 +188,7 @@ if [ $ec -eq 0 ]; then |
| 188 | 188 |
ec=$? |
| 189 | 189 |
set +x |
| 190 | 190 |
if [ 0 -ne $ec ]; then |
| 191 |
- echo "ERROR: Failed to compile and start the linux daemon" |
|
| 191 |
+ echo "ERROR: Failed to compile and start the linux daemon" |
|
| 192 | 192 |
fi |
| 193 | 193 |
fi |
| 194 | 194 |
|
| ... | ... |
@@ -199,7 +199,7 @@ if [ $ec -eq 0 ]; then |
| 199 | 199 |
export TIMEOUT="5m" |
| 200 | 200 |
export DOCKER_HOST="tcp://$ip:$port_inner" |
| 201 | 201 |
export DOCKER_TEST_HOST="tcp://$ip:$port_inner" |
| 202 |
- unset DOCKER_CLIENTONLY |
|
| 202 |
+ unset DOCKER_CLIENTONLY |
|
| 203 | 203 |
export DOCKER_REMOTE_DAEMON=1 |
| 204 | 204 |
hack/make.sh binary |
| 205 | 205 |
ec=$? |