8

I'm trying to deploy an application using docker-compose through Docker Context. I'm using this guide: https://www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/

The problem comes when I try to create a context. e.g.: docker context create test --docker "host=ssh://user@remotehost" I get this:

"docker context create" requires exactly 1 argument. See 'docker context create --help'.

This only happens on Windows WSL, on Linux it works flawlessly.

I'm using docker 19.03.8 with Experimental Features enabled.

veben
  • 19,637
  • 14
  • 60
  • 80
Raul
  • 515
  • 1
  • 6
  • 13

3 Answers3

31

It's because of the dash character. Compare the two commands (notice the two dashes before "docker")

Failed command:
docker context create test --docker "host=ssh://user@remotehost"

Successful command:
docker context create test ‐‐docker "host=ssh://user@remotehost"

These dashes look the same but have different character codes, the command line interpreter treats them as letters

oklas
  • 7,935
  • 2
  • 26
  • 42
Huajun Zeng
  • 311
  • 2
  • 3
  • 1
    yeah, encountered it too, copy-paste from web , thanks :) – dmirkitanov Apr 04 '21 at 08:16
  • 3
    Can you please explain how these two lines are different? they look identical to me. – Mai Elshiashi Jun 11 '22 at 14:30
  • @MaiElshiashi when utf-8 decoded
    ‐‐docker (failed command)
    \xE2\x80\x90\xE2\x80\x90\x64\x6F\x63\x6B\x65\x72
    --docker (successful command)
    \x2D\x2D\x64\x6F\x63\x6B\x65\x72
    dash at the bottom makes it gray telling it's a option in vscode pwd
    – ccppoo Sep 11 '22 at 14:45
2

There were 2 issues combined in my case (M1 mac). Weird -- symbols copied from web + skip the quotes:

docker context create --docker host=ssh://user@ip xxx

Hope it helps.

Martin
  • 638
  • 1
  • 5
  • 13
0

Options should go before context. ie :"docker context create --docker host=ssh://user@remotehost test". See documentation: https://docs.docker.com/engine/reference/commandline/context_create/

  • Maybe Judah meant this @Raul `docker context create --docker "host=ssh://user@remotehost test `? You can see examples like this on the linked docs. – cam Feb 22 '21 at 20:04
  • Yes I know. Same result. – Raul Feb 22 '21 at 23:15