hi all,
I was trying to create a new context to work with AWS so from everything I researched, it looks like the following command should work:
docker context create ecs myeccontext
when I run the above command, I get the following error.
“docker context create” requires exactly 1 argument.
See ‘docker context create --help’.
Usage: docker context create [OPTIONS] CONTEXT
Create a context
I’m running docker on MacOS Monterey 12.5.1
docker --version
Docker version 20.10.17, build 100c70180f
current context list:
docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
desktop-linux unix:///Users/username/.docker/run/docker.sock
I can log into AWS as the below command shows I can log in:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ***************90.dkr.ecr.us-east-1.amazonaws.com
Login Succeeded
It works on my Mac, same versions. Are you sure you didn’t have a typo in your command? Is the command that you shared here the exact same command that you ran in the terminal or did you typed the command again here without a typo?
For example this works:
docker context create ecs myeccontext
and this gives me the same error as you had:
docker context create eccs myeccontext
since ecs is a valid command but eccs is not so docker context create expects a context name where eccs is and myeccontext would be an other argument of create, but it has only one. If you write the right command, then ecs is a subcommand of create and myeccontext is an argument of ecs and not create.
I can’t reproduce the issue, so unfortunately I don’t know who I could help you.
The only thing I noticed in your configuration is that you use Docker desktop, but when you listed your Docker contexts, it looks like the activate context is not Docker Desktop, but Docker CE.
curl -L https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5982 100 5982 0 0 17610 0 --:--:-- --:--:-- --:--:-- 18182
Running checks...
Error: Script not needed on macOS, please install Docker Desktop Edge: https://www.docker.com/products/docker-desktop
I’m not using Docker Desktop. My environment is a Linux machine (Ubuntu 22.04) with docker engine installed. Just posted that installing compose-cli solved my issue.
@tfgcampos The Docker Desktop part of my message was a reply to @jedmittendevo, not for you. Sorry for the confusion.
Yes, and this is what I am curious about Does docker context create ecs contextname worked for you just because you installed Docker Compose or you had a different problem and you used only Docker Compose not docker context create?
I needed to create an ECS context to run a workload in AWS, and original docker command don’t have support to ECS. Now that I have compose-cli and docker engine installed, I can simulated both scenarios running /usr/bin/docker (docker engine’s one) or /usr/local/bin/docker (compose-cli’s one):
running /usr/bin/docker
~$ /usr/bin/docker context create ecs test
"docker context create" requires exactly 1 argument.
See 'docker context create --help'.
Usage: docker context create [OPTIONS] CONTEXT
Create a context
running /usr/local/bin/docker
~$ /usr/local/bin/docker context create ecs test
? Create a Docker context using: An existing AWS profile
? Select AWS Profile default
Successfully created ecs context "test"
Probably this is the issue @xender2022 is facing. There is probably two docker executables, and PATH defines the search path priority for execution. It’s worth trying to execute ‘whereis docker’ to check if other executables exists. Below is mine:
I realized I was completely wrong when I wrote this:
I ignored the fact that you just wrote that you used macOS so it could not have been Docker CE…
Thank you for sharing your solution. Strange, because the installer of Docker Compose should not install an other docker binary and it indeed does. I can confirm it know and I could also reproduce the issue. I guess it worked for me because I tried on my mac, but when I ran a virtual machine on macOS using multipass, the pre-installed docker cli did not understand ecs, but the other one did.
It is strange, because the two docker binary gives me the same information when I run docker version, but they are different and they have different size. So something is wrong here, but I am glad that you finally found the cause.
Looks like i had the same issue with jed. As soon as I specifically used /usr/local/bin/docker, the context command finally worked.
Also removed homebrew installed docker so that the default docker is ran from /usr/local/bin.