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

why to sleep for 20 seconds? #183

Open
vv12131415 opened this issue Jul 29, 2020 · 11 comments · May be fixed by #455
Open

why to sleep for 20 seconds? #183

vv12131415 opened this issue Jul 29, 2020 · 11 comments · May be fixed by #455

Comments

@vv12131415
Copy link

I see this line

( set -x; sleep 20 )

and also others. I don't really understand why should I sleep for 20 sec?

@thaJeztah
Copy link
Member

Because otherwise the user wouldn't be able to act on the warnings that are printed;

docker-install/install.sh

Lines 237 to 258 in 2e839c9

cat >&2 <<-'EOF'
Warning: the "docker" command appears to already exist on this system.
If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
If you installed the current Docker package using this script and are using it
EOF
if [ $shouldWarn -eq 1 ]; then
cat >&2 <<-'EOF'
again to update Docker, we urge you to migrate your image store before upgrading
to v1.10+.
You can find instructions for this here:
https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration
EOF
else
cat >&2 <<-'EOF'
again to update Docker, you can safely ignore this message.
EOF

@vv12131415
Copy link
Author

Oh, I was using this script in my dotfiles, and thought that I wait too long

@nemchik
Copy link

nemchik commented Jul 29, 2020

I use the script in a similar way and actually think it would be nice to be able to bypass the sleep by setting an environment variable or passing a flag or something.

@thaJeztah
Copy link
Member

What's the reason you're getting the error? If you're using the script to update to a newer version, using the regular way to update packages (apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io, or the equivalent yum/dnf commands) might be better

@nemchik
Copy link

nemchik commented Jul 29, 2020

The sleep happens when this condition is met

if command_exists docker; then
even though one of the potential scenarios already accounted for displays a message informing the user they can safely ignore the message
again to update Docker, you can safely ignore this message.
in which scenario I would ideally want the option to also skip the sleep when calling this script as part of another script's installation procedure. 20 seconds isn't hurting anyone, but if the option to skip it is being considered I can confirm it would be useful and would be used.

Also just to clarify, what I'm asking is along the lines of setting an environment variable prior to running the script that would be something like SKIP_DOCKER_CE_INSTALL_SLEEP_WARNING=true or something that's very intentional. I would also consider some kind of flag when running like bash docker-install.sh --skip-sleep-when-docker-already-exists=true (maybe not that long as a flag, but point being it wouldn't be something passed on accident like -s).

@thaJeztah
Copy link
Member

Oh, I was using this script in my dotfiles,

I'm still curious when the script is called / used in your use-case to get a better understanding; Is it to keep your docker installation up-to-date? How do you keep other packages up to date (and wouldn't docker be included in the same process?)

informing the user they can safely ignore the message

So, first of all, situations where I think this scenario can be problematic (and where the script is not suitable for updating);

  • If the docker command was detected, but a different package is installed (either a distro package, or perhaps podman and people set alias docker=podman). In this case, the warning definitely should not be ignored.
  • I think the script actually needs an update to account for the fact that it's no longer installing a single package, but multiple (cli, daemon, containers), to make the "update" scenario work correctly; the current script only explicitly installs docker-ce, and relies on the dependencies defined in the .deb / .rpm packages to install the CLI and containerd. This works ok for the "fresh" install case (due to the dependency chain), but could lead to the docker-ce-cli and containerd.io packages not being updated on existing installs;
    $sh_c "apt-get install -y -qq --no-install-recommends docker-ce$pkg_version >/dev/null"
  • After upgrading the system (although this is not specific to the script); if, for example, I upgrade my Ubuntu 18.04 machine to Ubuntu 20.04, the package repositories added by the script would still point to the 18.04 package repositories. To make the script work well for upgrading/updating, that should probably be addressed.

Also just to clarify, what I'm asking is along the lines of setting an environment variable prior to running the script that would be something like SKIP_DOCKER_CE_INSTALL_SLEEP_WARNING=true or something that's very intentional. I would also consider some kind of flag when running like bash docker-install.sh --skip-sleep-when-docker-already-exists=true (maybe not that long as a flag, but point being it wouldn't be something passed on accident like -s).

Perhaps it could looks for DEBIAN_FRONTEND=noninteractive and/or similar options for rpm-based platforms. I do think that ideally the points above would be addressed though, otherwise the script would not work well for the upgrade scenario, and I'd rather have a warning then this being ignored "silently"

@tianon any thoughts?

@lake2
Copy link

lake2 commented Aug 15, 2020

same issue +1. I need a flag to skip this sleeping.

@tianon
Copy link
Contributor

tianon commented Dec 19, 2020

@tianon any thoughts?

I mean, you know my thoughts on this script... 😅

(I would've deprecated it years ago - I think it does more harm than good. 😇)

The idea of folks using it inside their dotfiles is honestly kind of terrifying, and I'd love to hear more about the intended use case too.

@MartinGolding515
Copy link

I also have a use case for this - creating an azure devops agent docker file where I need to install docker within the docker image

@warmfire540
Copy link

+1 - we're installing docker inside a dotnet/core Linux image so that we can build and push the .NET projects to docker.

It's giving me a warning that WSL is detected and pauses for 20 seconds during the docker compose - would be nice to be able to avoid the 20s

@jonasbadstuebner
Copy link

curl -fsSL https://get.docker.com | awk -v new_command_exists_function='command_exists() { if [ "$1" = "docker" ]; then return 1; else command -v "$@" > /dev/null 2>&1; fi }' '/^command_exists/,/^\}/ { if ( $0 ~ /\}/ ) print new_command_exists_function; next } 1' | sh
Replaces the command_exists function with a one that returns non-zero if the commmand to check for is docker.
Maybe this helps?

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.

8 participants