Wowu / docker-rollout

🚀 Zero Downtime Deployment for Docker Compose
https://github.com/Wowu/docker-rollout
MIT License
2.18k stars 59 forks source link

Problems using on alpine based images while running docker in docker #19

Closed damey2011 closed 4 months ago

damey2011 commented 7 months ago

This is not really anymore an issue at least for me, but just to make it easier for someone who runs into similar issue as well. Even after following the guide, I ran into issues like:

docker: 'rollout' is not a docker command.
See 'docker --help'

AND

grep: unrecognized option: invert-match
BusyBox v1.36.1 (2023-07-27 17:12:24 UTC) multi-call binary.
Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
Search for PATTERN in FILEs (or stdin)
    -H  Add 'filename:' prefix
    -h  Do not add 'filename:' prefix
    -n  Add 'line_no:' prefix
    -l  Show only names of files that match
    -L  Show only names of files that don't match
    -c  Show only count of matching lines
    -o  Show only the matching part of line
    -q  Quiet. Return 0 if PATTERN is found, 1 otherwise
    -v  Select non-matching lines
    -s  Suppress open and read errors
    -r  Recurse
    -R  Recurse and dereference symlinks
    -i  Ignore case
    -w  Match whole words only
    -x  Match whole lines only
    -F  PATTERN is a literal (not regexp)
    -E  PATTERN is an extended regexp
    -m N    Match up to N times per file
    -A N    Print N lines of trailing context
    -B N    Print N lines of leading context
    -C N    Same as '-A N -B N'
    -e PTRN Pattern to match
    -f FILE Read pattern from file

For the first issue of rollout is not a docker command. If you run docker info, you'd see that docker fails to load the plugin and returns a warning as part of the message as follows:

WARNING: Plugin "/usr/local/libexec/docker/cli-plugins/docker-rollout" is not valid: failed to fetch metadata: fork/exec /usr/local/libexec/docker/cli-plugins/docker-rollout: no such file or directory

The problem here is that the docker-rollout plugin is being executed or supported on only bash currently. This might be a very trivial issue to resolve. I'd try to create an PR to fix this, but in the meantime, it's easy to document this issue. The easy solution is to install bash in your alpine image.

apk add --update bash && rm -rf /var/cache/apk/*

Also, for the issue with grep, your alpine image comes with a stripped down grep package. You can fix this by simply running

apk add --no-cache --upgrade grep

These took me a couple of hours to resolve, but I thought it could save someone a lot of developer hours as well. Nevertheless, I'll during my leisure time, develop an MR to address this.

Feel free to leave this open if it's cool to have this support, or close the issue if this is outside of the scope of the tool.

Wowu commented 7 months ago

Thanks for sharing @damey2011! Maybe I can try to rewrite the script to use sh only, and basic grep features. Or at least check the availability of both programs and display a friendly message.

damey2011 commented 7 months ago

Yeah. That would make a huge difference.

rcknr commented 5 months ago

@damey2011 Could you please help test the version from #22?

theupriser commented 4 months ago

I tested it, it works! only the cut -f 1 w command does not seem to work because the -w argument is not known on alpine.

image

It does continue though.

I can’t really find what -w does anyway.

rcknr commented 4 months ago

@theupriser Thanks for taking the time to test! I have updated the code with an equivalent of the unsupported -w option.

theupriser commented 4 months ago

@rcknr Alright that's nice and fast! Thanks!

edit: tested the commit, seems to work all fine!

Wowu commented 4 months ago

Fixed in #22

Wowu commented 4 months ago

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