├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE ├── MAINTAINERS ├── Makefile ├── NOTICE ├── README.md ├── install.sh ├── rootless-install.sh └── verify-docker-install /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | **- What I did** 17 | 18 | **- How I did it** 19 | 20 | **- How to verify it** 21 | 22 | **- Description for the changelog** 23 | 27 | 28 | 29 | **- A picture of a cute animal (not mandatory but encouraged)** 30 | 31 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: docker-install CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | timeout-minutes: 5 9 | strategy: 10 | matrix: 11 | os: 12 | - ubuntu:22.04 13 | - ubuntu:24.04 14 | - quay.io/centos/centos:stream9 15 | version: 16 | - "27.5" 17 | - "" 18 | 19 | steps: 20 | - uses: actions/checkout@v3 21 | - name: Shellcheck 22 | run: make shellcheck 23 | - name: Check distribution 24 | run: TEST_IMAGE=${{ matrix.os }} VERSION=${{ matrix.version }} make test 25 | 26 | # This is a separate workflow step, because we need to check it outside of container (due to lsmod, iptables checks) 27 | test-install-rootless: 28 | runs-on: ubuntu-latest 29 | timeout-minutes: 5 30 | steps: 31 | - uses: actions/checkout@v3 32 | - name: Install rootless 33 | run: | 34 | sudo sh -c 'echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns' 35 | FORCE_ROOTLESS_INSTALL=1 ./rootless-install.sh 36 | 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *verify-install-* 2 | build/ 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2013-2017 Docker, Inc. 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | https://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. 191 | -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | # Project maintainers file 2 | # 3 | # This file describes who runs the docker/docker-install project and how. 4 | # This is a living document - if you see something out of date or missing, speak up! 5 | # 6 | # It is structured to be consumable by both humans and programs. 7 | # To extract its contents programmatically, use any TOML-compliant parser. 8 | # 9 | # This file is compiled into the MAINTAINERS file in docker/opensource. 10 | # 11 | [Org] 12 | [Org."Core maintainers"] 13 | people = [ 14 | "seemethere", 15 | "andrewhsu", 16 | "thajeztah" 17 | ] 18 | 19 | [people] 20 | 21 | # A reference list of all people associated with the project. 22 | # All other sections should refer to people by their canonical key 23 | # in the people section. 24 | 25 | # ADD YOURSELF HERE IN ALPHABETICAL ORDER 26 | 27 | [people.andrewhsu] 28 | Name = "Andrew Hsu" 29 | Email = "andrewhsu@docker.com" 30 | GitHub = "andrewhsu" 31 | 32 | [people.seemethere] 33 | Name = "Eli Uriegas" 34 | Email = "seemethere101@gmail.com" 35 | GitHub = "seemethere" 36 | 37 | [people.thajeztah] 38 | Name = "Sebastiaan van Stijn" 39 | Email = "github@gone.nl" 40 | GitHub = "thaJeztah" 41 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TEST_IMAGE?=ubuntu:22.04 2 | VERSION?= 3 | CHANNEL?= 4 | 5 | VOLUME_MOUNTS=-v "$(CURDIR)":/v 6 | SHELLCHECK_EXCLUSIONS=$(addprefix -e, SC1091 SC1117 SC2317 SC2329) 7 | SHELLCHECK=docker run --rm $(VOLUME_MOUNTS) -w /v koalaman/shellcheck:stable $(SHELLCHECK_EXCLUSIONS) 8 | 9 | ENVSUBST_VARS=LOAD_SCRIPT_COMMIT_SHA 10 | 11 | .PHONY: build 12 | build: build/install.sh 13 | 14 | build/install.sh: install.sh 15 | mkdir -p $(@D) 16 | LOAD_SCRIPT_COMMIT_SHA='$(shell git rev-parse HEAD)' envsubst '$(addprefix $$,$(ENVSUBST_VARS))' < $< > $@ 17 | 18 | .PHONY: shellcheck 19 | shellcheck: build/install.sh 20 | $(SHELLCHECK) $< 21 | 22 | .PHONY: test 23 | test: build/install.sh 24 | docker run --rm -i \ 25 | $(VOLUME_MOUNTS) \ 26 | -w /v \ 27 | -e VERSION \ 28 | -e CHANNEL \ 29 | $(TEST_IMAGE) \ 30 | sh "$<" 31 | 32 | .PHONY: clean 33 | clean: 34 | $(RM) -r build/ 35 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Docker 2 | Copyright 2013-2017 Docker, Inc. 3 | 4 | This product includes software developed at Docker, Inc. (https://www.docker.com). 5 | 6 | This product contains software (https://github.com/kr/pty) developed 7 | by Keith Rarick, licensed under the MIT License. 8 | 9 | The following is courtesy of our legal counsel: 10 | 11 | 12 | Use and transfer of Docker may be subject to certain restrictions by the 13 | United States and other governments. 14 | It is your responsibility to ensure that your use and/or transfer does not 15 | violate applicable laws. 16 | 17 | For more information, please see https://www.bis.doc.gov 18 | 19 | See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker/docker-install 2 | Home of the script that lives at `get.docker.com` and `test.docker.com`! 3 | 4 | The purpose of the install script is for a convenience for quickly 5 | installing the latest Docker-CE releases on the supported linux 6 | distros. It is not recommended to depend on this script for deployment 7 | to production systems. For more thorough instructions for installing 8 | on the supported distros, see the [install 9 | instructions](https://docs.docker.com/engine/install/). 10 | 11 | This repository is solely maintained by Docker, Inc. 12 | 13 | ## Usage: 14 | 15 | From `https://get.docker.com`: 16 | ```shell 17 | curl -fsSL https://get.docker.com -o get-docker.sh 18 | sh get-docker.sh 19 | ``` 20 | 21 | From `https://test.docker.com`: 22 | ```shell 23 | curl -fsSL https://test.docker.com -o test-docker.sh 24 | sh test-docker.sh 25 | ``` 26 | 27 | From the source repo (This will install latest from the `stable` channel): 28 | ```shell 29 | sh install.sh 30 | ``` 31 | 32 | ## Testing: 33 | 34 | To verify that the install script works amongst the supported operating systems run: 35 | 36 | ```shell 37 | make shellcheck 38 | ``` 39 | 40 | ## Legal 41 | *Brought to you courtesy of our legal counsel. For more context, 42 | please see the [NOTICE](NOTICE) document in this repo.* 43 | 44 | Use and transfer of Docker may be subject to certain restrictions by the 45 | United States and other governments. 46 | 47 | It is your responsibility to ensure that your use and/or transfer does not 48 | violate applicable laws. 49 | 50 | For more information, please see https://www.bis.doc.gov 51 | 52 | ## Reporting security issues 53 | 54 | The maintainers take security seriously. If you discover a security issue, 55 | please bring it to their attention right away! 56 | 57 | Please **DO NOT** file a public issue, instead send your report privately to 58 | [security@docker.com](mailto:security@docker.com). 59 | 60 | Security reports are greatly appreciated and we will publicly thank you for it. 61 | We also like to send gifts—if you're into Docker schwag, make sure to let 62 | us know. We currently do not offer a paid security bounty program, but are not 63 | ruling it out in the future. 64 | 65 | ## Licensing 66 | 67 | docker/docker-install is licensed under the Apache License, Version 2.0. 68 | See [LICENSE](LICENSE) for the full license text. 69 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | # Docker Engine for Linux installation script. 4 | # 5 | # This script is intended as a convenient way to configure docker's package 6 | # repositories and to install Docker Engine, This script is not recommended 7 | # for production environments. Before running this script, make yourself familiar 8 | # with potential risks and limitations, and refer to the installation manual 9 | # at https://docs.docker.com/engine/install/ for alternative installation methods. 10 | # 11 | # The script: 12 | # 13 | # - Requires `root` or `sudo` privileges to run. 14 | # - Attempts to detect your Linux distribution and version and configure your 15 | # package management system for you. 16 | # - Doesn't allow you to customize most installation parameters. 17 | # - Installs dependencies and recommendations without asking for confirmation. 18 | # - Installs the latest stable release (by default) of Docker CLI, Docker Engine, 19 | # Docker Buildx, Docker Compose, containerd, and runc. When using this script 20 | # to provision a machine, this may result in unexpected major version upgrades 21 | # of these packages. Always test upgrades in a test environment before 22 | # deploying to your production systems. 23 | # - Isn't designed to upgrade an existing Docker installation. When using the 24 | # script to update an existing installation, dependencies may not be updated 25 | # to the expected version, resulting in outdated versions. 26 | # 27 | # Source code is available at https://github.com/docker/docker-install/ 28 | # 29 | # Usage 30 | # ============================================================================== 31 | # 32 | # To install the latest stable versions of Docker CLI, Docker Engine, and their 33 | # dependencies: 34 | # 35 | # 1. download the script 36 | # 37 | # $ curl -fsSL https://get.docker.com -o install-docker.sh 38 | # 39 | # 2. verify the script's content 40 | # 41 | # $ cat install-docker.sh 42 | # 43 | # 3. run the script with --dry-run to verify the steps it executes 44 | # 45 | # $ sh install-docker.sh --dry-run 46 | # 47 | # 4. run the script either as root, or using sudo to perform the installation. 48 | # 49 | # $ sudo sh install-docker.sh 50 | # 51 | # Command-line options 52 | # ============================================================================== 53 | # 54 | # --version 55 | # Use the --version option to install a specific version, for example: 56 | # 57 | # $ sudo sh install-docker.sh --version 23.0 58 | # 59 | # --channel 60 | # 61 | # Use the --channel option to install from an alternative installation channel. 62 | # The following example installs the latest versions from the "test" channel, 63 | # which includes pre-releases (alpha, beta, rc): 64 | # 65 | # $ sudo sh install-docker.sh --channel test 66 | # 67 | # Alternatively, use the script at https://test.docker.com, which uses the test 68 | # channel as default. 69 | # 70 | # --mirror 71 | # 72 | # Use the --mirror option to install from a mirror supported by this script. 73 | # Available mirrors are "Aliyun" (https://mirrors.aliyun.com/docker-ce), and 74 | # "AzureChinaCloud" (https://mirror.azure.cn/docker-ce), for example: 75 | # 76 | # $ sudo sh install-docker.sh --mirror AzureChinaCloud 77 | # 78 | # ============================================================================== 79 | 80 | 81 | # Git commit from https://github.com/docker/docker-install when 82 | # the script was uploaded (Should only be modified by upload job): 83 | SCRIPT_COMMIT_SHA="${LOAD_SCRIPT_COMMIT_SHA}" 84 | 85 | # strip "v" prefix if present 86 | VERSION="${VERSION#v}" 87 | 88 | # The channel to install from: 89 | # * stable 90 | # * test 91 | DEFAULT_CHANNEL_VALUE="stable" 92 | if [ -z "$CHANNEL" ]; then 93 | CHANNEL=$DEFAULT_CHANNEL_VALUE 94 | fi 95 | 96 | DEFAULT_DOWNLOAD_URL="https://download.docker.com" 97 | if [ -z "$DOWNLOAD_URL" ]; then 98 | DOWNLOAD_URL=$DEFAULT_DOWNLOAD_URL 99 | fi 100 | 101 | DEFAULT_REPO_FILE="docker-ce.repo" 102 | if [ -z "$REPO_FILE" ]; then 103 | REPO_FILE="$DEFAULT_REPO_FILE" 104 | # Automatically default to a staging repo fora 105 | # a staging download url (download-stage.docker.com) 106 | case "$DOWNLOAD_URL" in 107 | *-stage*) REPO_FILE="docker-ce-staging.repo";; 108 | esac 109 | fi 110 | 111 | mirror='' 112 | DRY_RUN=${DRY_RUN:-} 113 | while [ $# -gt 0 ]; do 114 | case "$1" in 115 | --channel) 116 | CHANNEL="$2" 117 | shift 118 | ;; 119 | --dry-run) 120 | DRY_RUN=1 121 | ;; 122 | --mirror) 123 | mirror="$2" 124 | shift 125 | ;; 126 | --version) 127 | VERSION="${2#v}" 128 | shift 129 | ;; 130 | --*) 131 | echo "Illegal option $1" 132 | ;; 133 | esac 134 | shift $(( $# > 0 ? 1 : 0 )) 135 | done 136 | 137 | case "$mirror" in 138 | Aliyun) 139 | DOWNLOAD_URL="https://mirrors.aliyun.com/docker-ce" 140 | ;; 141 | AzureChinaCloud) 142 | DOWNLOAD_URL="https://mirror.azure.cn/docker-ce" 143 | ;; 144 | "") 145 | ;; 146 | *) 147 | >&2 echo "unknown mirror '$mirror': use either 'Aliyun', or 'AzureChinaCloud'." 148 | exit 1 149 | ;; 150 | esac 151 | 152 | case "$CHANNEL" in 153 | stable|test) 154 | ;; 155 | *) 156 | >&2 echo "unknown CHANNEL '$CHANNEL': use either stable or test." 157 | exit 1 158 | ;; 159 | esac 160 | 161 | command_exists() { 162 | command -v "$@" > /dev/null 2>&1 163 | } 164 | 165 | # version_gte checks if the version specified in $VERSION is at least the given 166 | # SemVer (Maj.Minor[.Patch]), or CalVer (YY.MM) version.It returns 0 (success) 167 | # if $VERSION is either unset (=latest) or newer or equal than the specified 168 | # version, or returns 1 (fail) otherwise. 169 | # 170 | # examples: 171 | # 172 | # VERSION=23.0 173 | # version_gte 23.0 // 0 (success) 174 | # version_gte 20.10 // 0 (success) 175 | # version_gte 19.03 // 0 (success) 176 | # version_gte 26.1 // 1 (fail) 177 | version_gte() { 178 | if [ -z "$VERSION" ]; then 179 | return 0 180 | fi 181 | version_compare "$VERSION" "$1" 182 | } 183 | 184 | # version_compare compares two version strings (either SemVer (Major.Minor.Path), 185 | # or CalVer (YY.MM) version strings. It returns 0 (success) if version A is newer 186 | # or equal than version B, or 1 (fail) otherwise. Patch releases and pre-release 187 | # (-alpha/-beta) are not taken into account 188 | # 189 | # examples: 190 | # 191 | # version_compare 23.0.0 20.10 // 0 (success) 192 | # version_compare 23.0 20.10 // 0 (success) 193 | # version_compare 20.10 19.03 // 0 (success) 194 | # version_compare 20.10 20.10 // 0 (success) 195 | # version_compare 19.03 20.10 // 1 (fail) 196 | version_compare() ( 197 | set +x 198 | 199 | yy_a="$(echo "$1" | cut -d'.' -f1)" 200 | yy_b="$(echo "$2" | cut -d'.' -f1)" 201 | if [ "$yy_a" -lt "$yy_b" ]; then 202 | return 1 203 | fi 204 | if [ "$yy_a" -gt "$yy_b" ]; then 205 | return 0 206 | fi 207 | mm_a="$(echo "$1" | cut -d'.' -f2)" 208 | mm_b="$(echo "$2" | cut -d'.' -f2)" 209 | 210 | # trim leading zeros to accommodate CalVer 211 | mm_a="${mm_a#0}" 212 | mm_b="${mm_b#0}" 213 | 214 | if [ "${mm_a:-0}" -lt "${mm_b:-0}" ]; then 215 | return 1 216 | fi 217 | 218 | return 0 219 | ) 220 | 221 | is_dry_run() { 222 | if [ -z "$DRY_RUN" ]; then 223 | return 1 224 | else 225 | return 0 226 | fi 227 | } 228 | 229 | is_wsl() { 230 | case "$(uname -r)" in 231 | *microsoft* ) true ;; # WSL 2 232 | *Microsoft* ) true ;; # WSL 1 233 | * ) false;; 234 | esac 235 | } 236 | 237 | is_darwin() { 238 | case "$(uname -s)" in 239 | *darwin* ) true ;; 240 | *Darwin* ) true ;; 241 | * ) false;; 242 | esac 243 | } 244 | 245 | deprecation_notice() { 246 | distro=$1 247 | distro_version=$2 248 | echo 249 | printf "\033[91;1mDEPRECATION WARNING\033[0m\n" 250 | printf " This Linux distribution (\033[1m%s %s\033[0m) reached end-of-life and is no longer supported by this script.\n" "$distro" "$distro_version" 251 | echo " No updates or security fixes will be released for this distribution, and users are recommended" 252 | echo " to upgrade to a currently maintained version of $distro." 253 | echo 254 | printf "Press \033[1mCtrl+C\033[0m now to abort this script, or wait for the installation to continue." 255 | echo 256 | sleep 10 257 | } 258 | 259 | get_distribution() { 260 | lsb_dist="" 261 | # Every system that we officially support has /etc/os-release 262 | if [ -r /etc/os-release ]; then 263 | lsb_dist="$(. /etc/os-release && echo "$ID")" 264 | fi 265 | # Returning an empty string here should be alright since the 266 | # case statements don't act unless you provide an actual value 267 | echo "$lsb_dist" 268 | } 269 | 270 | echo_docker_as_nonroot() { 271 | if is_dry_run; then 272 | return 273 | fi 274 | if command_exists docker && [ -e /var/run/docker.sock ]; then 275 | ( 276 | set -x 277 | $sh_c 'docker version' 278 | ) || true 279 | fi 280 | 281 | # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output 282 | echo 283 | echo "================================================================================" 284 | echo 285 | if version_gte "20.10"; then 286 | echo "To run Docker as a non-privileged user, consider setting up the" 287 | echo "Docker daemon in rootless mode for your user:" 288 | echo 289 | echo " dockerd-rootless-setuptool.sh install" 290 | echo 291 | echo "Visit https://docs.docker.com/go/rootless/ to learn about rootless mode." 292 | echo 293 | fi 294 | echo 295 | echo "To run the Docker daemon as a fully privileged service, but granting non-root" 296 | echo "users access, refer to https://docs.docker.com/go/daemon-access/" 297 | echo 298 | echo "WARNING: Access to the remote API on a privileged Docker daemon is equivalent" 299 | echo " to root access on the host. Refer to the 'Docker daemon attack surface'" 300 | echo " documentation for details: https://docs.docker.com/go/attack-surface/" 301 | echo 302 | echo "================================================================================" 303 | echo 304 | } 305 | 306 | # Check if this is a forked Linux distro 307 | check_forked() { 308 | 309 | # Check for lsb_release command existence, it usually exists in forked distros 310 | if command_exists lsb_release; then 311 | # Check if the `-u` option is supported 312 | set +e 313 | lsb_release -a -u > /dev/null 2>&1 314 | lsb_release_exit_code=$? 315 | set -e 316 | 317 | # Check if the command has exited successfully, it means we're in a forked distro 318 | if [ "$lsb_release_exit_code" = "0" ]; then 319 | # Print info about current distro 320 | cat <<-EOF 321 | You're using '$lsb_dist' version '$dist_version'. 322 | EOF 323 | 324 | # Get the upstream release info 325 | lsb_dist=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'id' | cut -d ':' -f 2 | tr -d '[:space:]') 326 | dist_version=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'codename' | cut -d ':' -f 2 | tr -d '[:space:]') 327 | 328 | # Print info about upstream distro 329 | cat <<-EOF 330 | Upstream release is '$lsb_dist' version '$dist_version'. 331 | EOF 332 | else 333 | if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "raspbian" ]; then 334 | if [ "$lsb_dist" = "osmc" ]; then 335 | # OSMC runs Raspbian 336 | lsb_dist=raspbian 337 | else 338 | # We're Debian and don't even know it! 339 | lsb_dist=debian 340 | fi 341 | dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')" 342 | case "$dist_version" in 343 | 13) 344 | dist_version="trixie" 345 | ;; 346 | 12) 347 | dist_version="bookworm" 348 | ;; 349 | 11) 350 | dist_version="bullseye" 351 | ;; 352 | 10) 353 | dist_version="buster" 354 | ;; 355 | 9) 356 | dist_version="stretch" 357 | ;; 358 | 8) 359 | dist_version="jessie" 360 | ;; 361 | esac 362 | fi 363 | fi 364 | fi 365 | } 366 | 367 | do_install() { 368 | echo "# Executing docker install script, commit: $SCRIPT_COMMIT_SHA" 369 | 370 | if command_exists docker; then 371 | cat >&2 <<-'EOF' 372 | Warning: the "docker" command appears to already exist on this system. 373 | 374 | If you already have Docker installed, this script can cause trouble, which is 375 | why we're displaying this warning and provide the opportunity to cancel the 376 | installation. 377 | 378 | If you installed the current Docker package using this script and are using it 379 | again to update Docker, you can ignore this message, but be aware that the 380 | script resets any custom changes in the deb and rpm repo configuration 381 | files to match the parameters passed to the script. 382 | 383 | You may press Ctrl+C now to abort this script. 384 | EOF 385 | ( set -x; sleep 20 ) 386 | fi 387 | 388 | user="$(id -un 2>/dev/null || true)" 389 | 390 | sh_c='sh -c' 391 | if [ "$user" != 'root' ]; then 392 | if command_exists sudo; then 393 | sh_c='sudo -E sh -c' 394 | elif command_exists su; then 395 | sh_c='su -c' 396 | else 397 | cat >&2 <<-'EOF' 398 | Error: this installer needs the ability to run commands as root. 399 | We are unable to find either "sudo" or "su" available to make this happen. 400 | EOF 401 | exit 1 402 | fi 403 | fi 404 | 405 | if is_dry_run; then 406 | sh_c="echo" 407 | fi 408 | 409 | # perform some very rudimentary platform detection 410 | lsb_dist=$( get_distribution ) 411 | lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')" 412 | 413 | if is_wsl; then 414 | echo 415 | echo "WSL DETECTED: We recommend using Docker Desktop for Windows." 416 | echo "Please get Docker Desktop from https://www.docker.com/products/docker-desktop/" 417 | echo 418 | cat >&2 <<-'EOF' 419 | 420 | You may press Ctrl+C now to abort this script. 421 | EOF 422 | ( set -x; sleep 20 ) 423 | fi 424 | 425 | case "$lsb_dist" in 426 | 427 | ubuntu) 428 | if command_exists lsb_release; then 429 | dist_version="$(lsb_release --codename | cut -f2)" 430 | fi 431 | if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then 432 | dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")" 433 | fi 434 | ;; 435 | 436 | debian|raspbian) 437 | dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')" 438 | case "$dist_version" in 439 | 13) 440 | dist_version="trixie" 441 | ;; 442 | 12) 443 | dist_version="bookworm" 444 | ;; 445 | 11) 446 | dist_version="bullseye" 447 | ;; 448 | 10) 449 | dist_version="buster" 450 | ;; 451 | 9) 452 | dist_version="stretch" 453 | ;; 454 | 8) 455 | dist_version="jessie" 456 | ;; 457 | esac 458 | ;; 459 | 460 | centos|rhel) 461 | if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then 462 | dist_version="$(. /etc/os-release && echo "$VERSION_ID")" 463 | fi 464 | ;; 465 | 466 | *) 467 | if command_exists lsb_release; then 468 | dist_version="$(lsb_release --release | cut -f2)" 469 | fi 470 | if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then 471 | dist_version="$(. /etc/os-release && echo "$VERSION_ID")" 472 | fi 473 | ;; 474 | 475 | esac 476 | 477 | # Check if this is a forked Linux distro 478 | check_forked 479 | 480 | # Print deprecation warnings for distro versions that recently reached EOL, 481 | # but may still be commonly used (especially LTS versions). 482 | case "$lsb_dist.$dist_version" in 483 | centos.8|centos.7|rhel.7) 484 | deprecation_notice "$lsb_dist" "$dist_version" 485 | ;; 486 | debian.buster|debian.stretch|debian.jessie) 487 | deprecation_notice "$lsb_dist" "$dist_version" 488 | ;; 489 | raspbian.buster|raspbian.stretch|raspbian.jessie) 490 | deprecation_notice "$lsb_dist" "$dist_version" 491 | ;; 492 | ubuntu.focal|ubuntu.bionic|ubuntu.xenial|ubuntu.trusty) 493 | deprecation_notice "$lsb_dist" "$dist_version" 494 | ;; 495 | ubuntu.mantic|ubuntu.lunar|ubuntu.kinetic|ubuntu.impish|ubuntu.hirsute|ubuntu.groovy|ubuntu.eoan|ubuntu.disco|ubuntu.cosmic) 496 | deprecation_notice "$lsb_dist" "$dist_version" 497 | ;; 498 | fedora.*) 499 | if [ "$dist_version" -lt 41 ]; then 500 | deprecation_notice "$lsb_dist" "$dist_version" 501 | fi 502 | ;; 503 | esac 504 | 505 | # Run setup for each distro accordingly 506 | case "$lsb_dist" in 507 | ubuntu|debian|raspbian) 508 | pre_reqs="ca-certificates curl" 509 | apt_repo="deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] $DOWNLOAD_URL/linux/$lsb_dist $dist_version $CHANNEL" 510 | ( 511 | if ! is_dry_run; then 512 | set -x 513 | fi 514 | $sh_c 'apt-get -qq update >/dev/null' 515 | $sh_c "DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $pre_reqs >/dev/null" 516 | $sh_c 'install -m 0755 -d /etc/apt/keyrings' 517 | $sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" -o /etc/apt/keyrings/docker.asc" 518 | $sh_c "chmod a+r /etc/apt/keyrings/docker.asc" 519 | $sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list" 520 | $sh_c 'apt-get -qq update >/dev/null' 521 | ) 522 | pkg_version="" 523 | if [ -n "$VERSION" ]; then 524 | if is_dry_run; then 525 | echo "# WARNING: VERSION pinning is not supported in DRY_RUN" 526 | else 527 | # Will work for incomplete versions IE (17.12), but may not actually grab the "latest" if in the test channel 528 | pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/~ce~.*/g' | sed 's/-/.*/g')" 529 | search_command="apt-cache madison docker-ce | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3" 530 | pkg_version="$($sh_c "$search_command")" 531 | echo "INFO: Searching repository for VERSION '$VERSION'" 532 | echo "INFO: $search_command" 533 | if [ -z "$pkg_version" ]; then 534 | echo 535 | echo "ERROR: '$VERSION' not found amongst apt-cache madison results" 536 | echo 537 | exit 1 538 | fi 539 | if version_gte "18.09"; then 540 | search_command="apt-cache madison docker-ce-cli | grep '$pkg_pattern' | head -1 | awk '{\$1=\$1};1' | cut -d' ' -f 3" 541 | echo "INFO: $search_command" 542 | cli_pkg_version="=$($sh_c "$search_command")" 543 | fi 544 | pkg_version="=$pkg_version" 545 | fi 546 | fi 547 | ( 548 | pkgs="docker-ce${pkg_version%=}" 549 | if version_gte "18.09"; then 550 | # older versions didn't ship the cli and containerd as separate packages 551 | pkgs="$pkgs docker-ce-cli${cli_pkg_version%=} containerd.io" 552 | fi 553 | if version_gte "20.10"; then 554 | pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version" 555 | fi 556 | if version_gte "23.0"; then 557 | pkgs="$pkgs docker-buildx-plugin docker-model-plugin" 558 | fi 559 | if ! is_dry_run; then 560 | set -x 561 | fi 562 | $sh_c "DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $pkgs >/dev/null" 563 | ) 564 | echo_docker_as_nonroot 565 | exit 0 566 | ;; 567 | centos|fedora|rhel) 568 | if [ "$(uname -m)" = "s390x" ]; then 569 | echo "Effective v27.5, please consult RHEL distro statement for s390x support." 570 | exit 1 571 | fi 572 | repo_file_url="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE" 573 | ( 574 | if ! is_dry_run; then 575 | set -x 576 | fi 577 | if command_exists dnf5; then 578 | $sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core" 579 | $sh_c "dnf5 config-manager addrepo --overwrite --save-filename=docker-ce.repo --from-repofile='$repo_file_url'" 580 | 581 | if [ "$CHANNEL" != "stable" ]; then 582 | $sh_c "dnf5 config-manager setopt \"docker-ce-*.enabled=0\"" 583 | $sh_c "dnf5 config-manager setopt \"docker-ce-$CHANNEL.enabled=1\"" 584 | fi 585 | $sh_c "dnf makecache" 586 | elif command_exists dnf; then 587 | $sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core" 588 | $sh_c "rm -f /etc/yum.repos.d/docker-ce.repo /etc/yum.repos.d/docker-ce-staging.repo" 589 | $sh_c "dnf config-manager --add-repo $repo_file_url" 590 | 591 | if [ "$CHANNEL" != "stable" ]; then 592 | $sh_c "dnf config-manager --set-disabled \"docker-ce-*\"" 593 | $sh_c "dnf config-manager --set-enabled \"docker-ce-$CHANNEL\"" 594 | fi 595 | $sh_c "dnf makecache" 596 | else 597 | $sh_c "yum -y -q install yum-utils" 598 | $sh_c "rm -f /etc/yum.repos.d/docker-ce.repo /etc/yum.repos.d/docker-ce-staging.repo" 599 | $sh_c "yum-config-manager --add-repo $repo_file_url" 600 | 601 | if [ "$CHANNEL" != "stable" ]; then 602 | $sh_c "yum-config-manager --disable \"docker-ce-*\"" 603 | $sh_c "yum-config-manager --enable \"docker-ce-$CHANNEL\"" 604 | fi 605 | $sh_c "yum makecache" 606 | fi 607 | ) 608 | pkg_version="" 609 | if command_exists dnf; then 610 | pkg_manager="dnf" 611 | pkg_manager_flags="-y -q --best" 612 | else 613 | pkg_manager="yum" 614 | pkg_manager_flags="-y -q" 615 | fi 616 | if [ -n "$VERSION" ]; then 617 | if is_dry_run; then 618 | echo "# WARNING: VERSION pinning is not supported in DRY_RUN" 619 | else 620 | if [ "$lsb_dist" = "fedora" ]; then 621 | pkg_suffix="fc$dist_version" 622 | else 623 | pkg_suffix="el" 624 | fi 625 | pkg_pattern="$(echo "$VERSION" | sed 's/-ce-/\\\\.ce.*/g' | sed 's/-/.*/g').*$pkg_suffix" 626 | search_command="$pkg_manager list --showduplicates docker-ce | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'" 627 | pkg_version="$($sh_c "$search_command")" 628 | echo "INFO: Searching repository for VERSION '$VERSION'" 629 | echo "INFO: $search_command" 630 | if [ -z "$pkg_version" ]; then 631 | echo 632 | echo "ERROR: '$VERSION' not found amongst $pkg_manager list results" 633 | echo 634 | exit 1 635 | fi 636 | if version_gte "18.09"; then 637 | # older versions don't support a cli package 638 | search_command="$pkg_manager list --showduplicates docker-ce-cli | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'" 639 | cli_pkg_version="$($sh_c "$search_command" | cut -d':' -f 2)" 640 | fi 641 | # Cut out the epoch and prefix with a '-' 642 | pkg_version="-$(echo "$pkg_version" | cut -d':' -f 2)" 643 | fi 644 | fi 645 | ( 646 | pkgs="docker-ce$pkg_version" 647 | if version_gte "18.09"; then 648 | # older versions didn't ship the cli and containerd as separate packages 649 | if [ -n "$cli_pkg_version" ]; then 650 | pkgs="$pkgs docker-ce-cli-$cli_pkg_version containerd.io" 651 | else 652 | pkgs="$pkgs docker-ce-cli containerd.io" 653 | fi 654 | fi 655 | if version_gte "20.10"; then 656 | pkgs="$pkgs docker-compose-plugin docker-ce-rootless-extras$pkg_version" 657 | fi 658 | if version_gte "23.0"; then 659 | pkgs="$pkgs docker-buildx-plugin docker-model-plugin" 660 | fi 661 | if ! is_dry_run; then 662 | set -x 663 | fi 664 | $sh_c "$pkg_manager $pkg_manager_flags install $pkgs" 665 | ) 666 | echo_docker_as_nonroot 667 | exit 0 668 | ;; 669 | sles) 670 | echo "Effective v27.5, please consult SLES distro statement for s390x support." 671 | exit 1 672 | ;; 673 | *) 674 | if [ -z "$lsb_dist" ]; then 675 | if is_darwin; then 676 | echo 677 | echo "ERROR: Unsupported operating system 'macOS'" 678 | echo "Please get Docker Desktop from https://www.docker.com/products/docker-desktop" 679 | echo 680 | exit 1 681 | fi 682 | fi 683 | echo 684 | echo "ERROR: Unsupported distribution '$lsb_dist'" 685 | echo 686 | exit 1 687 | ;; 688 | esac 689 | exit 1 690 | } 691 | 692 | # wrapped up in a function so that we have some protection against only getting 693 | # half the file during "curl | sh" 694 | do_install 695 | -------------------------------------------------------------------------------- /rootless-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | # Docker CE for Linux installation script (Rootless mode) 4 | # 5 | # See https://docs.docker.com/go/rootless/ for the 6 | # installation steps. 7 | # 8 | # This script is meant for quick & easy install via: 9 | # $ curl -fsSL https://get.docker.com/rootless -o get-docker.sh 10 | # $ sh get-docker.sh 11 | # 12 | # NOTE: Make sure to verify the contents of the script 13 | # you downloaded matches the contents of install.sh 14 | # located at https://github.com/docker/docker-install 15 | # before executing. 16 | # 17 | # Git commit from https://github.com/docker/docker-install when 18 | # the script was uploaded (Should only be modified by upload job): 19 | SCRIPT_COMMIT_SHA=UNKNOWN 20 | 21 | # This script should be run with an unprivileged user and install/setup Docker under $HOME/bin/. 22 | 23 | # latest version available in the stable channel. 24 | STABLE_LATEST="28.2.1" 25 | 26 | # latest version available in the test channel. 27 | TEST_LATEST="28.2.1" 28 | 29 | # The channel to install from: 30 | # * test 31 | # * stable 32 | DEFAULT_CHANNEL_VALUE="stable" 33 | if [ -z "$CHANNEL" ]; then 34 | CHANNEL=$DEFAULT_CHANNEL_VALUE 35 | fi 36 | 37 | STATIC_RELEASE_URL= 38 | STATIC_RELEASE_ROOTLESS_URL= 39 | case "$CHANNEL" in 40 | "stable") 41 | echo "# Installing stable version ${STABLE_LATEST}" 42 | STATIC_RELEASE_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-${STABLE_LATEST}.tgz" 43 | STATIC_RELEASE_ROOTLESS_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-rootless-extras-${STABLE_LATEST}.tgz" 44 | ;; 45 | "test") 46 | echo "# Installing test version ${TEST_LATEST}" 47 | STATIC_RELEASE_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-${TEST_LATEST}.tgz" 48 | STATIC_RELEASE_ROOTLESS_URL="https://download.docker.com/linux/static/$CHANNEL/$(uname -m)/docker-rootless-extras-${TEST_LATEST}.tgz" 49 | ;; 50 | *) 51 | >&2 echo "Aborting because of unknown CHANNEL \"$CHANNEL\". Set \$CHANNEL to either \"stable\" or \"test\"." 52 | exit 1 53 | ;; 54 | esac 55 | 56 | init_vars() { 57 | BIN="${DOCKER_BIN:-$HOME/bin}" 58 | 59 | DAEMON=dockerd 60 | SYSTEMD= 61 | if systemctl --user daemon-reload >/dev/null 2>&1; then 62 | SYSTEMD=1 63 | fi 64 | } 65 | 66 | checks() { 67 | # OS verification: Linux only, point osx/win to helpful locations 68 | case "$(uname)" in 69 | Linux) 70 | ;; 71 | *) 72 | >&2 echo "Rootless Docker cannot be installed on $(uname)"; exit 1 73 | ;; 74 | esac 75 | 76 | # User verification: deny running as root (unless forced?) 77 | if [ "$(id -u)" = "0" ] && [ -z "$FORCE_ROOTLESS_INSTALL" ]; then 78 | >&2 echo "Refusing to install rootless Docker as the root user"; exit 1 79 | fi 80 | 81 | # HOME verification 82 | if [ ! -d "$HOME" ]; then 83 | >&2 echo "Aborting because HOME directory $HOME does not exist"; exit 1 84 | fi 85 | 86 | if [ -d "$BIN" ]; then 87 | if [ ! -w "$BIN" ]; then 88 | >&2 echo "Aborting because $BIN is not writable"; exit 1 89 | fi 90 | else 91 | if [ ! -w "$HOME" ]; then 92 | >&2 echo "Aborting because HOME (\"$HOME\") is not writable"; exit 1 93 | fi 94 | fi 95 | 96 | # Existing rootful docker verification 97 | if [ -w /var/run/docker.sock ] && [ -z "$FORCE_ROOTLESS_INSTALL" ]; then 98 | >&2 echo "Aborting because rootful Docker is running and accessible. Set FORCE_ROOTLESS_INSTALL=1 to ignore."; exit 1 99 | fi 100 | 101 | # Validate XDG_RUNTIME_DIR 102 | if [ ! -w "$XDG_RUNTIME_DIR" ]; then 103 | if [ -n "$SYSTEMD" ]; then 104 | >&2 echo "Aborting because systemd was detected but XDG_RUNTIME_DIR (\"$XDG_RUNTIME_DIR\") does not exist or is not writable" 105 | >&2 echo "Hint: this could happen if you changed users with 'su' or 'sudo'. To work around this:" 106 | >&2 echo "- try again by first running with root privileges 'loginctl enable-linger ' where is the unprivileged user and export XDG_RUNTIME_DIR to the value of RuntimePath as shown by 'loginctl show-user '" 107 | >&2 echo "- or simply log back in as the desired unprivileged user (ssh works for remote machines)" 108 | exit 1 109 | fi 110 | fi 111 | 112 | # Already installed verification (unless force?). Only having docker cli binary previously shouldn't fail the build. 113 | if [ -x "$BIN/$DAEMON" ]; then 114 | # If rootless installation is detected print out the modified PATH and DOCKER_HOST that needs to be set. 115 | echo "# Existing rootless Docker detected at $BIN/$DAEMON" 116 | echo 117 | echo "# To reinstall or upgrade rootless Docker, run the following commands and then rerun the installation script:" 118 | echo "systemctl --user stop docker" 119 | echo "rm -f $BIN/$DAEMON" 120 | echo 121 | echo "# Alternatively, install the docker-ce-rootless-extras RPM/deb package for ease of package management (requires root)." 122 | echo "# See https://docs.docker.com/go/rootless/ for details." 123 | exit 0 124 | fi 125 | 126 | INSTRUCTIONS= 127 | 128 | # uidmap dependency check 129 | if ! command -v newuidmap >/dev/null 2>&1; then 130 | if command -v apt-get >/dev/null 2>&1; then 131 | INSTRUCTIONS="apt-get -y install uidmap" 132 | elif command -v dnf >/dev/null 2>&1; then 133 | INSTRUCTIONS="dnf -y install shadow-utils" 134 | elif command -v yum >/dev/null 2>&1; then 135 | INSTRUCTIONS="curl -o /etc/yum.repos.d/vbatts-shadow-utils-newxidmap-epel-7.repo https://copr.fedorainfracloud.org/coprs/vbatts/shadow-utils-newxidmap/repo/epel-7/vbatts-shadow-utils-newxidmap-epel-7.repo 136 | yum -y install shadow-utils46-newxidmap" 137 | else 138 | echo "newuidmap binary not found. Please install with a package manager." 139 | exit 1 140 | fi 141 | fi 142 | 143 | # iptables dependency check 144 | if [ -z "$SKIP_IPTABLES" ] && ! command -v iptables >/dev/null 2>&1 && [ ! -f /sbin/iptables ] && [ ! -f /usr/sbin/iptables ]; then 145 | if command -v apt-get >/dev/null 2>&1; then 146 | INSTRUCTIONS="${INSTRUCTIONS} 147 | apt-get -y install iptables" 148 | elif command -v dnf >/dev/null 2>&1; then 149 | INSTRUCTIONS="${INSTRUCTIONS} 150 | dnf -y install iptables" 151 | else 152 | echo "iptables binary not found. Please install with a package manager." 153 | exit 1 154 | fi 155 | fi 156 | 157 | # ip_tables module dependency check 158 | if [ -z "$SKIP_IPTABLES" ] && ! lsmod | grep ip_tables >/dev/null 2>&1 && ! grep -q ip_tables "/lib/modules/$(uname -r)/modules.builtin"; then 159 | INSTRUCTIONS="${INSTRUCTIONS} 160 | modprobe ip_tables" 161 | fi 162 | 163 | # debian requires setting unprivileged_userns_clone 164 | if [ -f /proc/sys/kernel/unprivileged_userns_clone ]; then 165 | if [ "1" != "$(cat /proc/sys/kernel/unprivileged_userns_clone)" ]; then 166 | INSTRUCTIONS="${INSTRUCTIONS} 167 | cat < /etc/sysctl.d/50-rootless.conf 168 | kernel.unprivileged_userns_clone = 1 169 | EOT 170 | sysctl --system" 171 | fi 172 | fi 173 | 174 | # centos requires setting max_user_namespaces 175 | if [ -f /proc/sys/user/max_user_namespaces ]; then 176 | if [ "0" = "$(cat /proc/sys/user/max_user_namespaces)" ]; then 177 | INSTRUCTIONS="${INSTRUCTIONS} 178 | cat < /etc/sysctl.d/51-rootless.conf 179 | user.max_user_namespaces = 28633 180 | EOT 181 | sysctl --system" 182 | fi 183 | fi 184 | 185 | if [ -n "$INSTRUCTIONS" ]; then 186 | echo "# Missing system requirements. Please run following commands to 187 | # install the requirements and run this installer again. 188 | # Alternatively iptables checks can be disabled with SKIP_IPTABLES=1" 189 | 190 | echo 191 | echo "cat </dev/null 2>&1; then 200 | >&2 echo "Could not find records for the current user $(id -un) from /etc/subuid . Please make sure valid subuid range is set there. 201 | For example: 202 | echo \"$(id -un):100000:65536\" >> /etc/subuid" 203 | exit 1 204 | fi 205 | if ! grep "^$(id -un):\|^$(id -u):" /etc/subgid >/dev/null 2>&1; then 206 | >&2 echo "Could not find records for the current user $(id -un) from /etc/subgid . Please make sure valid subuid range is set there. 207 | For example: 208 | echo \"$(id -un):100000:65536\" >> /etc/subgid" 209 | exit 1 210 | fi 211 | } 212 | 213 | exec_setuptool() { 214 | if [ -n "$FORCE_ROOTLESS_INSTALL" ]; then 215 | set -- "$@" --force 216 | fi 217 | if [ -n "$SKIP_IPTABLES" ]; then 218 | set -- "$@" --skip-iptables 219 | fi 220 | ( 221 | set -x 222 | PATH="$BIN:$PATH" "$BIN/dockerd-rootless-setuptool.sh" install "$@" 223 | ) 224 | } 225 | 226 | do_install() { 227 | echo "# Executing docker rootless install script, commit: $SCRIPT_COMMIT_SHA" 228 | 229 | init_vars 230 | checks 231 | 232 | tmp=$(mktemp -d) 233 | trap 'rm -rf "$tmp"' EXIT INT TERM 234 | # Download tarballs docker-* and docker-rootless-extras=* 235 | ( 236 | cd "$tmp" 237 | curl -L -o docker.tgz "$STATIC_RELEASE_URL" 238 | curl -L -o rootless.tgz "$STATIC_RELEASE_ROOTLESS_URL" 239 | ) 240 | # Extract under $HOME/bin/ 241 | ( 242 | mkdir -p "$BIN" 243 | cd "$BIN" 244 | tar zxf "$tmp/docker.tgz" --strip-components=1 245 | tar zxf "$tmp/rootless.tgz" --strip-components=1 246 | ) 247 | 248 | exec_setuptool "$@" 249 | } 250 | 251 | do_install "$@" 252 | -------------------------------------------------------------------------------- /verify-docker-install: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | ( 3 | echo "INFO: Executing installation script!" 4 | sh build/install.sh 5 | ) 6 | 7 | # Verify that we can at least get version output 8 | if ! docker --version; then 9 | echo "ERROR: Did Docker get installed?" 10 | exit 1 11 | fi 12 | 13 | # Attempt to run a container if not in a container 14 | if [ ! -f /.dockerenv ]; then 15 | if ! docker run --rm hello-world; then 16 | echo "ERROR: Could not get docker to run the hello world container" 17 | exit 2 18 | fi 19 | fi 20 | 21 | echo "INFO: Successfully verified docker installation!" 22 | --------------------------------------------------------------------------------