Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support docker --context #13

Closed
tadamcz opened this issue Aug 22, 2023 · 6 comments · Fixed by #17
Closed

Support docker --context #13

tadamcz opened this issue Aug 22, 2023 · 6 comments · Fixed by #17

Comments

@tadamcz
Copy link

tadamcz commented Aug 22, 2023

Could you support the docker --context flag?

It's used like this, to take the example from the Docker docs:

docker --context production container ls

I suppose you'd need to change something around here:

  -*)
    echo "Unknown option: $1"
    exit_with_usage
    ;;
  *)

and here:

# check if compose v2 is available
if docker compose >/dev/null 2>&1; then
  COMPOSE_COMMAND="docker compose"
elif docker-compose >/dev/null 2>&1; then
  COMPOSE_COMMAND="docker-compose"
else
  echo "docker compose or docker-compose is required"
  exit 1
fi

Shell scripting is not at all my strength so I'm hesitant to dive in myself.

@Wowu
Copy link
Owner

Wowu commented Aug 23, 2023

I decided not to implement all possible docker and docker compose flags if they can be provided via an environment variable to keep this tool simple, would this work for your use case?

env DOCKER_CONTEXT=production docker rollout

(See Docker profiles #5 (comment) and remote deployment #6 (comment))

@tadamcz
Copy link
Author

tadamcz commented Aug 23, 2023

Yes this works OK.

I had thought you could just pass arbitrary additional flags to docker and compose as follows.

i.e.

docker --xyz rollout passes xyz to docker

And docker rollout --xyz passes xyz to compose

@Wowu
Copy link
Owner

Wowu commented Aug 23, 2023

Actually, it sounds like a good idea to pass unknown flags, but there's a catch: the script uses docker and docker compose, and those have different flags available. I think environment variables are a nice solution, especially for a bash script tool.

@tadamcz
Copy link
Author

tadamcz commented Aug 23, 2023

Not sure I understand the problem; you could pass them like I described in the last comment? Is there something wrong with my suggestion?

Obviously the decision of how to spend your time is entirely yours. Thanks for the tool :)

@Wowu
Copy link
Owner

Wowu commented Aug 23, 2023

Oh sorry, I didn't get your idea at first. Would be great, but I'm not sure if I'm able to access flags passed to docker commands, because the docker plugin integration is pretty basic. Will check

@Wowu
Copy link
Owner

Wowu commented Oct 13, 2023

It works as I expected, thank you for the suggestion. Arguments before rollout are now passed to docker commands, so --context now works.

Released as https://github.com/Wowu/docker-rollout/releases/tag/v0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants