Ubuntu 26.10 (stonking) images no longer ship /etc/lsb-release, and
the base image has no lsb_release command.
Both codename lookups returned nothing, so the apt source line had no
suite and apt-get update failed:
```
deb [...] https://download-stage.docker.com/linux/ubuntu test
E: Malformed entry 1 in list file /etc/apt/sources.list.d/docker.list (Component)
```
Read VERSION_CODENAME from /etc/os-release first, which every supported
Ubuntu release provides and get_distribution already relies on.
lsb_release and /etc/lsb-release remain as fallbacks when os-release has
no codename.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Allow users to opt into installing the docker-sbx package alongside
the standard Docker Engine packages by setting SBX=1, for example:
curl -fsSL https://get.docker.com | sudo SBX=1 sh
This mirrors the existing pattern used by other env vars (CHANNEL,
VERSION, etc.) and adds the docker-sbx package to the apt and
dnf/yum install package lists when SBX is set to "1".
Signed-off-by: Eric Curtin <eric.curtin@docker.com>
Make sure both pkg_version and cli_pkg_version are only set on success
to prevent them containing a bare "=", which we were stripping later on.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
When REPO_ONLY=1, the script only sets up the package repository and
exits. There's no reason to warn about Docker being already installed or
sleep for 20 seconds in that case.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This PR makes the Docker daemon start automatically after installation
by default, with a --no-autostart opt-out flag. This addresses issue #124
and aligns with the "opinionated convenience" philosophy of get.docker.com.
Changes:
- Autostart enabled by default (AUTOSTART=1)
- Added --no-autostart flag to opt-out
- Smart systemd detection using /run/systemd/system directory check
- Falls back to traditional service management (service/chkconfig/update-rc.d)
- Uses sh_c pattern for proper dry-run support
- All informational messages output to stderr
The systemd detection checks for /run/systemd/system directory which only
exists when systemd is actually running as PID 1. This prevents failures
in container environments where systemctl is installed but systemd is not
running.
Tested across all supported distributions:
- Ubuntu (20.04, 22.04, 24.04)
- Debian (11, 12)
- CentOS Stream (8, 9)
- Fedora (40, 41)
- RHEL/AlmaLinux (8, 9)
Fixes#124
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Gajesh Bhat <gajeshbht@gmail.com>
The `--setup-repo` flag allows users to add Docker package repositories
to without automatically installing Docker packages.
This is useful for scenarios where users want to configure the
repository but handle package installation separately.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
On ubuntu bionic and focal (and debian buster too), the docker-model-plugin
package is missing. The suggestion was to just install the package named
docker-buildx-plugin in the version 23 check, while moving the missing
package docker-model-plugin to a new version 28.2 check. The number was
chosen because that package becomes available starting with version 28.2
on ubuntu jammy (while not available in version 28.1 on ubuntu focal).
See: https://github.com/docker/docker-install/issues/509
Signed-off-by: Rejean Groleau <rejeangroleau@gmail.com>
When using a staging download URL (containing "-stage" in the URL), and
no explicit repo was provided automatically use the staging repo file as
well.
So it's sufficient to do:
```
curl -L get.docker.com | DOWNLOAD_URL="https://download-stage.docker.com" sh -
```
instead of
```
curl -L get.docker.com | REPO_FILE="docker-ce-staging.repo" DOWNLOAD_URL="https://download-stage.docker.com" sh -
```
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
The installation script's main purpose is to perform a fresh install, because
it's not guaranteed to work correctly when updating an existing installation,
and we print a warning if we find docker is already installed. However, it's
known that the script is used to update existing installations.
The current script has some limitations for the update scenario;
- When using the script for installing from the staging domain, the existing
repo configuration is not overwritten. When using `yum`, or older `dnf` versions
this resulted in 2 separate repo files to be created (docker-ce.repo and
docker-ce-staging.repo), which resulted in errors due to duplicate repo
definitions with the same name.
- When using `dnf5`, we specified the filename to store the configuration,
which resulted in an error;
+ sh -c 'dnf5 config-manager addrepo --save-filename=docker-ce.repo --from-repofile='\''https://download-stage.docker.com/linux/fedora/docker-ce-staging.repo'\'''
File "/etc/yum.repos.d/docker-ce.repo" already exists and configures repositories with IDs "docker-ce-stable docker-ce-stable-debuginfo docker-ce-stable-source docker-ce-test docker-ce-test-debuginfo docker-ce-test-source docker-ce-nightly docker-ce-nightly-debuginfo docker-ce-nightly-source". Add "--overwrite" to overwrite.
- On SLES, it would result in a similar error;
+ sh -c 'zypper addrepo https://download-stage.docker.com/linux/sles/docker-ce-staging.repo'
Adding repository 'Docker CE Nightly - s390x' ......................................................................................[error]
Repository named 'docker-ce-nightly' already exists. Please use another alias.
Adding repository 'Docker CE Nightly - Debuginfo s390x' ............................................................................[error]
Repository named 'docker-ce-nightly-debuginfo' already exists. Please use another alias.
This patch updates the script to overwrite / replace the existing repo config.
This brings the rpm-based installations in line with the Debian approach, which
unconditionally overwrites `/etc/apt/sources.list.d/docker.list`.
It's worth noting that this change will therefore overwrite any customisations
made to the repo-configurations, so a warning is added for that.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
commit 766b70c5be quoted these values to
prevent globbing, but used single quotes. However, these commands are
executed with `sh -c` using single quotes, which makes the output hard
to read because of the embedded quotes being escaped.
This patch changes to use double-quotes, which should still prevent
globbing to happen, but make the output more readable.
Before:
CHANNEL=test ./install.sh
...
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
+ '[' test '!=' stable ']'
+ sh -c 'dnf config-manager --set-disabled '\''docker-ce-*'\'''
+ sh -c 'dnf config-manager --set-enabled '\''docker-ce-test'\'''
+ sh -c 'dnf makecache'
After:
CHANNEL=test ./install.sh
...
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
+ '[' test '!=' stable ']'
+ sh -c 'dnf config-manager --set-disabled "docker-ce-*"'
+ sh -c 'dnf config-manager --set-enabled "docker-ce-test"'
+ sh -c 'dnf makecache'
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The addrepo command has a bug that causes it to fail if the `.repo` file
contains empty lines, causing it to fail;
dnf config-manager addrepo --from-repofile="https://download.docker.com/linux/fedora/docker-ce.repo"
Error in added repository configuration file. Cannot set repository option "#1=
": Option "#1" not found
Use a temporary file and strip empty lines as a workaround until the bug
is fixed.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
We only need the config-manager, but it comes with a large number of weak
dependencies;
dnf -q install dnf-plugins-core
Transaction Summary:
Installing: 78 packages
Disable weak dependencies to skip those, as they're not essential for this
script;
dnf -q --setopt=install_weak_deps=False install dnf-plugins-core
Transaction Summary:
Installing: 32 packages
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Fedora 41 and up use the new dnf5 as default, which is a rewrite of
the dnf commands with different options;
+ dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Unknown argument "--add-repo" for command "config-manager". Add "--help" for more information about the arguments.
make: *** [Makefile:95: verify] Error 2
script returned exit code 2
This patch:
- adds a check for dnf5
- removes some indirection through env-vars, and instead inlines the code
Note that with CentOS 7 being EOL, we can probably remove the `yum` variant
from the script, but I left those in place for now.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The `-y` and `-q` options are global options, and can be set before the
command that's run;
apt-get --help
...
Usage: apt-get [options] command
apt-get [options] install|remove pkg1 [pkg2 ...]
apt-get [options] source pkg1 [pkg2 ...]
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The `-y` and `-q` options are global options, and can be set before the
command that's run. There's some ambiguity in the USAGE output of different
versions (`yum`, `dnf`, `dnf5`)
yum always outputs the same usage, but shows that options go _before_
the command;
yum --help
Usage: yum [options] COMMAND
yum install --help
Usage: yum [options] COMMAND
dnf (dnf4) is ambiguous; when showing usage for `install` it shows the
options to be set _after_ the command;
dnf install --help
usage: dnf install [-c [config file]] [-q] [-v] [--version] ....
but the global `--help` shows them to be before the command;
dnf --help
usage: dnf [options] COMMAND
General DNF options:
...
-q, --quiet quiet operation
-v, --verbose verbose operation
,,,
--setopt SETOPTS set arbitrary config and repo options
dnf5 is more explicit about global vs per-command options;
dnf --help
Usage:
dnf5 [GLOBAL OPTIONS] <COMMAND> ...
dnf install --help
Usage:
dnf5 [GLOBAL OPTIONS] install [OPTIONS] [ARGUMENTS]
Testing shows that older versions (`dnf4` and `yum`) handle both fine,
and because `dnf5` (per the above) prefers global options to go before
the command, we can use that convention in this script.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This check was added in 63fb2060c9, at which
time we did not provide packages fro RHEL on architectures other than s390x.
We now provide packages for RHEL 8 and 9 for amd64 (x86), arm64, and s390x,
so we can remove this check.
Note that we do not (yet?) provide packages for ppc64le, but this is more
of a niche use-case, so not adding a special condition for that, as we
don't provide that check for other distros.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>