{"id":13452410,"url":"https://github.com/rancher/install-docker","last_synced_at":"2025-03-23T19:34:20.174Z","repository":{"id":12323199,"uuid":"71597938","full_name":"rancher/install-docker","owner":"rancher","description":"Scripts for docker-machine to install a particular docker version","archived":false,"fork":false,"pushed_at":"2024-08-28T15:26:04.000Z","size":397,"stargazers_count":370,"open_issues_count":5,"forks_count":188,"subscribers_count":40,"default_branch":"master","last_synced_at":"2024-08-28T17:05:40.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rancher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-21T21:23:34.000Z","updated_at":"2024-08-28T15:26:09.000Z","dependencies_parsed_at":"2024-01-16T03:46:20.756Z","dependency_job_id":"47e7613e-50e9-463b-bf16-650a2de00811","html_url":"https://github.com/rancher/install-docker","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancher%2Finstall-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancher%2Finstall-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancher%2Finstall-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancher%2Finstall-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rancher","download_url":"https://codeload.github.com/rancher/install-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221900941,"owners_count":16898993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T07:01:23.382Z","updated_at":"2024-10-28T18:31:18.267Z","avatar_url":"https://github.com/rancher.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# install-docker\nScripts for docker-machine to install a particular docker version\n\nHosted at https://releases.rancher.com/install-docker/x.y[.z].sh, e.g.: \n\n  - https://releases.rancher.com/install-docker/20.10.sh\n\nTest bucket is located at https://releases.rancher.com/install-docker-dev/x.y[.z].sh\n\n## Currently released versions\n\n[![install-docker](https://img.shields.io/badge/dynamic/json?label=install-docker\u0026query=%24.version\u0026url=https%3A%2F%2Freleases.rancher.com%2Finstall-docker%2FVERSION)](https://github.com/rancher/install-docker/tags)\n[![install-docker-dev](https://img.shields.io/badge/dynamic/json?label=install-docker-dev\u0026query=%24.version\u0026url=https%3A%2F%2Freleases.rancher.com%2Finstall-docker-dev%2FVERSION)](https://github.com/rancher/install-docker/commits/master)\n\n## Add new docker release\n\nExample adding 20.10.7 with diff from 20.10.6:\n\n- Run `make add-new-version` with the previous and new version:\n```\nPREVIOUS_ADD_DOCKER_VERSION=20.10.6 ADD_DOCKER_VERSION=20.10.7 make add-new-version\n```\n- Generate distributed script by running `make generate`\n- Under `dist/` create/update the proper docker install script symlink `\u003cDOCKER_MAJOR\u003e.\u003cDOCKER_MINOR\u003e.sh`, to the generated script. Ex: `ln -s 20.10.7.sh 20.10.sh`\n- **Optional:** Run OS tests locally using `make test` (currently takes around 45 minutes)\n- Commit changes and submit PR (this will start the tests as well)\n\n## Test releases\n\nThe repo contains some tests to check if the docker install scripts are working fine on defined distros and versions. The tests are executed within a dind env for every `pkg/\u003cDOCKER_VERSION\u003e` folder, using the generated scripts to install and run docker on defined distros and versions.\n\n`make test`\n\nThere is the default distros and versions definition to test:\n```\nTEST_OS_IMAGE_NAME=(ubuntu centos debian)\nTEST_OS_IMAGE_TAG[0]=\"16.04 18.04 20.04\"\nTEST_OS_IMAGE_TAG[1]=\"centos7 centos8\"\nTEST_OS_IMAGE_TAG[2]=\"10\"\n```\n\nThe test definition can be overwritten on every docker version folder, using the shell script file `pkg/\u003cDOCKER_VERSION\u003e/config.sh`\n```\n#!/bin/sh\n\nDOCKER_GIT_COMMIT=\"3d8fe77c2c46c5b7571f94b42793905e5b3e42e4\"\n\nTEST_OS_IMAGE_NAME=(ubuntu centos debian)\nTEST_OS_IMAGE_TAG[0]=\"20.04\"\nTEST_OS_IMAGE_TAG[1]=\"centos7\"\nTEST_OS_IMAGE_TAG[2]=\"10\"\n```\n\n**Tip** As dind test env doesn't use systemd, dockerd is started manually. The default timeout waiting until dockerd starts, is defined by env variable `DIND_TEST_WAIT=3s`. It can be overwritten on execution time if required, `DIND_TEST_WAIT=5s make test`\n\n## Sync releases\n\nOn each merge to master, scripts in `dist/` will be uploaded to `install-docker-dev` bucket and can be retrieved using https://releases.rancher.com/install-docker-dev/$VERSION.sh. The commit of the version that was uploaded can be found on https://releases.rancher.com/install-docker-dev/VERSION\n\nWhen testing has been completed, the release job needs to be run to upload the scripts in `dist/` to `install-docker` (https://releases.rancher.com/install-docker/$VERSION.sh). A tag consists of the latest Docker version in the repository (for example, `20.10.12`) and epoch timestamp (in case we need to release same set of versions with changes). The release job will automatically create a tag and release the artifacts to the specified upload bucket. To initiate the release process, use the GitHub Actions workflow [Creates a tag and upload release](https://github.com/rancher/install-docker/actions/workflows/create-release.yml). You can find the tag of the version that was uploaded at https://releases.rancher.com/install-docker/VERSION\n\n## Previous manual instructions to add a new version\n\nThis script is based on public docker-install release, https://github.com/docker/docker-install . Docker-install script is built from the docker repo, and it's patched to generate a docker install script for a concrete docker version. The patch is also adding support for `oracle` and `rancheros` distros due to not supported on the original script.\n\nTo add a new docker installer version, follow these steps:\n- Create a docker version folder under `pkg/\u003cDOCKER_VERSION\u003e`, version should follow [semver](https://semver.org/) format.  Ex: `pkg/20.10.2/`\n- Under docker version folder: \n  - Download docker-install version from its repo `curl -Lsk http://get.docker.com/ -o \u003cDOCKER_VERSION\u003e.orig.sh` and make a copy `cp -p \u003cDOCKER_VERSION\u003e.orig.sh \u003cDOCKER_VERSION\u003e.sh`\n  - Make all the needed changes at `\u003cDOCKER_VERSION\u003e.sh`. Don't remove `SCRIPT_COMMIT_SHA` var definition\n  - Create diff file,  `diff -uNr \u003cDOCKER_VERSION\u003e.orig.sh \u003cDOCKER_VERSION\u003e.sh \u003e pkg/\u003cDOCKER_VERSION\u003e/\u003cDOCKER_VERSION\u003e.diff` and remove . Ex: `pkg/20.10.2/20.10.2.diff`\n```\n diff -uNr 20.10.2.orig.sh 20.10.2.sh\n--- 20.10.2.orig.sh 2021-01-28 23:47:45.000000000 +0100\n+++ 20.10.2.sh  2021-01-28 23:53:21.000000000 +0100\n@@ -21,26 +21,11 @@\n # the script was uploaded (Should only be modified by upload job):\n SCRIPT_COMMIT_SHA=\"3d8fe77c2c46c5b7571f94b42793905e5b3e42e4\"\n \n-\n-# The channel to install from:\n-#   * nightly\n-#   * test\n-#   * stable\n-#   * edge (deprecated)\n-DEFAULT_CHANNEL_VALUE=\"stable\"\n-if [ -z \"$CHANNEL\" ]; then\n- CHANNEL=$DEFAULT_CHANNEL_VALUE\n-fi\n-\n-DEFAULT_DOWNLOAD_URL=\"https://download.docker.com\"\n-if [ -z \"$DOWNLOAD_URL\" ]; then\n- DOWNLOAD_URL=$DEFAULT_DOWNLOAD_URL\n-fi\n-\n-DEFAULT_REPO_FILE=\"docker-ce.repo\"\n-if [ -z \"$REPO_FILE\" ]; then\n- REPO_FILE=\"$DEFAULT_REPO_FILE\"\n-fi\n+CHANNEL=\"stable\"\n+DOWNLOAD_URL=\"https://download.docker.com\"\n+REPO_FILE=\"docker-ce.repo\"\n+VERSION=20.10.2\n+DIND_TEST_WAIT=${DIND_TEST_WAIT:-3s}  # Wait time until docker start at dind test env\n \n mirror=''\n DRY_RUN=${DRY_RUN:-}\n@@ -69,6 +54,18 @@\n    ;;\n esac\n \n+start_docker() {\n+ if [ ! -z $DIND_TEST ]; then\n+   # Starting dockerd manually due to dind env is not using systemd\n+   dockerd \u0026\n+   sleep $DIND_TEST_WAIT\n+ elif [ -d '/run/systemd/system' ] ; then\n+   $sh_c 'systemctl start docker'\n+ else\n+   $sh_c 'service docker start'\n+ fi\n+}\n+\n command_exists() {\n  command -v \"$@\" \u003e /dev/null 2\u003e\u00261\n }\n@@ -329,11 +326,20 @@\n    ;;\n \n    centos|rhel)\n+     # installing centos packages\n+     lsb_dist=\"centos\"\n      if [ -z \"$dist_version\" ] \u0026\u0026 [ -r /etc/os-release ]; then\n        dist_version=\"$(. /etc/os-release \u0026\u0026 echo \"$VERSION_ID\")\"\n      fi\n    ;;\n \n+   oracleserver)\n+     # installing centos packages\n+     lsb_dist=\"centos\"\n+     # need to switch lsb_dist to match yum repo URL\n+     dist_version=\"$(rpm -q --whatprovides redhat-release --queryformat \"%{VERSION}\\n\" | sed 's/\\/.*//' | sed 's/\\..*//' | sed 's/Server*//')\"\n+   ;;\n+\n    *)\n      if command_exists lsb_release; then\n        dist_version=\"$(lsb_release --release | cut -f2)\"\n@@ -404,6 +410,7 @@\n          $sh_c \"apt-get install -y -qq --no-install-recommends docker-ce-cli=$cli_pkg_version \u003e/dev/null\"\n        fi\n        $sh_c \"apt-get install -y -qq --no-install-recommends docker-ce$pkg_version \u003e/dev/null\"\n+       start_docker\n      )\n      echo_docker_as_nonroot\n      exit 0\n@@ -474,10 +481,25 @@\n          $sh_c \"$pkg_manager install -y -q docker-ce-cli-$cli_pkg_version\"\n        fi\n        $sh_c \"$pkg_manager install -y -q docker-ce$pkg_version\"\n+       if ! command_exists iptables; then\n+         $sh_c \"$pkg_manager install -y -q iptables\"\n+       fi\n+       start_docker\n      )\n      echo_docker_as_nonroot\n      exit 0\n      ;;\n+   rancheros)\n+     (\n+     set -x\n+     $sh_c \"sleep 3;ros engine list --update\"\n+     engine_version=\"$(sudo ros engine list | awk '{print $2}' | grep ${docker_version} | tail -n 1)\"\n+     if [ \"$engine_version\" != \"\" ]; then\n+       $sh_c \"ros engine switch -f $engine_version\"\n+     fi\n+     )\n+     exit 0\n+     ;;\n    *)\n      if [ -z \"$lsb_dist\" ]; then\n        if is_darwin; then\n\n```\n  - Create shell script file `pkg/\u003cDOCKER_VERSION\u003e/config.sh`. To assure the patch would be applied to the same origin script version, this file should contain `DOCKER_GIT_COMMIT` var equal to `SCRIPT_COMMIT_SHA` got on first steps. Ex: [`pkg/20.10.2/config.sh`](pkg/20.10.2/config.sh)\n```\n#!/bin/sh\n\nDOCKER_GIT_COMMIT=\"3d8fe77c2c46c5b7571f94b42793905e5b3e42e4\"\n```\n  - Generate the docker version install script `dist/\u003cDOCKER_VERSION\u003e.sh` executing `make generate`. This command will generate docker version install script for every `pkg/\u003cDOCKER_VERSION\u003e` folder, if it doesn't exist and `pkg/\u003cDOCKER_VERSION\u003e/\u003cDOCKER_VERSION\u003e.diff` and `pkg/\u003cDOCKER_VERSION\u003e/config.sh` files exist. This command will also shows an info message for docker install scripts that were generated with older DOCKER_GIT_COMMIT, so they could be updated with latest released DOCKER_GIT_COMMIT. `git` and `curl` commands are required.\n  Ex: Will generate [`dist/20.10.2.sh`](dist/20.10.2.sh).\n  - Under `dist/` create/update the proper docker install script symlink `\u003cDOCKER_MAJOR\u003e.\u003cDOCKER_MINOR\u003e.sh`, to the generated script. Ex: `ln -s 20.10.2.sh 20.10.sh`\n  - Define and execute tests, `make test`. See above for more info\n  - Commit changes and submit PR \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Francher%2Finstall-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Francher%2Finstall-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Francher%2Finstall-docker/lists"}