docker-install icon indicating copy to clipboard operation
docker-install copied to clipboard

why to sleep for 20 seconds?

Open vv12131415 opened this issue 5 years ago • 11 comments

I see this line https://github.com/docker/docker-install/blob/2e839c9ac3e469baedcf74069d0e95200957d332/install.sh#L265 and also others. I don't really understand why should I sleep for 20 sec?

vv12131415 avatar Jul 29 '20 12:07 vv12131415

Because otherwise the user wouldn't be able to act on the warnings that are printed; https://github.com/docker/docker-install/blob/2e839c9ac3e469baedcf74069d0e95200957d332/install.sh#L237-L258

thaJeztah avatar Jul 29 '20 12:07 thaJeztah

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

vv12131415 avatar Jul 29 '20 13:07 vv12131415

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.

nemchik avatar Jul 29 '20 14:07 nemchik

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

thaJeztah avatar Jul 29 '20 14:07 thaJeztah

The sleep happens when this condition is met https://github.com/docker/docker-install/blob/2e839c9ac3e469baedcf74069d0e95200957d332/install.sh#L221 even though one of the potential scenarios already accounted for displays a message informing the user they can safely ignore the message https://github.com/docker/docker-install/blob/2e839c9ac3e469baedcf74069d0e95200957d332/install.sh#L257 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).

nemchik avatar Jul 29 '20 14:07 nemchik

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; https://github.com/docker/docker-install/blob/2e839c9ac3e469baedcf74069d0e95200957d332/install.sh#L406
  • 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?

thaJeztah avatar Jul 31 '20 13:07 thaJeztah

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

lake2 avatar Aug 15 '20 06:08 lake2

@tianon any thoughts?

I mean, you know my thoughts on this script... :sweat_smile:

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

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.

tianon avatar Dec 19 '20 01:12 tianon

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

MartinGolding515 avatar Jul 22 '21 18:07 MartinGolding515

+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

warmfire540 avatar Nov 04 '21 23:11 warmfire540

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?

jonasbadstuebner avatar Oct 12 '22 08:10 jonasbadstuebner