From 6d65baef6ef10cd3331ff247f7ddd7f66b8c728c Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Wed, 11 Dec 2024 22:46:39 +0000 Subject: [PATCH] Update documentation for container, exec and service (#1293) * Update documentation for container, exec and service Signed-off-by: Dan Webb * Update readme, and documentation folder Signed-off-by: Dan Webb * Update readme, and documentation folder Signed-off-by: Dan Webb * Fix default_script_url Signed-off-by: Dan Webb --------- Signed-off-by: Dan Webb --- CHANGELOG.md | 18 +- README.md | 22 +- documentation/docker_container.md | 212 +++++++++----- documentation/docker_exec.md | 73 ++++- documentation/docker_installation_package.md | 94 +++++++ documentation/docker_installation_script.md | 75 +++++ documentation/docker_installation_tarball.md | 84 ++++++ documentation/docker_service.md | 264 +++++++++++------- .../docker_service_manager_execute.md | 74 +++++ .../docker_service_manager_systemd.md | 98 +++++++ documentation/docker_volume_prune.md | 76 +++++ resources/installation_script.rb | 9 +- 12 files changed, 905 insertions(+), 194 deletions(-) create mode 100644 documentation/docker_installation_package.md create mode 100644 documentation/docker_installation_script.md create mode 100644 documentation/docker_installation_tarball.md create mode 100644 documentation/docker_service_manager_execute.md create mode 100644 documentation/docker_service_manager_systemd.md create mode 100644 documentation/docker_volume_prune.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 372e49c91..964349ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Update documentation for `docker_container` resource +- Update documentation for `docker_service` resource +- Update documentation for `docker_exec` resource +- Update resources overview +- Update documentation for `docker_installation_package` resource +- Update documentation for `docker_installation_script` resource +- Update documentation for `docker_installation_tarball` resource +- Update documentation for `docker_service_manager_execute` resource +- Update documentation for `docker_service_manager_systemd` resource +- Update documentation for `docker_volume_prune` resource +<<<<<<< HEAD + ## 11.8.3 - *2024-12-11* - Cleanup changelog +======= + +>>>>>>> 5326caf (Update readme, and documentation folder) ## 11.8.2 - *2024-12-11* @@ -808,6 +823,3 @@ The 7.0 release includes a breaking change to package installs with version spec - [#296](https://github.com/sous-chefs/docker/issues/296) - [#297](https://github.com/sous-chefs/docker/issues/297) - [#298](https://github.com/sous-chefs/docker/issues/298) - -[@jcrobak]: https://github.com/jcrobak -[@wingrunr21]: https://github.com/wingrunr21 diff --git a/README.md b/README.md index 1f0478a7b..989819d21 100644 --- a/README.md +++ b/README.md @@ -73,19 +73,21 @@ Those recipes are found at `test/cookbooks/docker_test`. ## Resources Overview - [docker_service](documentation/docker_service.md): composite resource that uses docker_installation and docker_service_manager -- [docker_installation](#docker_installation): automatically select an installation method -- [docker_service_manager](#docker_service_manager): automatically selects a service manager -- [docker_installation_script](#docker_installation_script): curl | bash -- [docker_installation_package](#docker_installation_package): package 'docker-ce' -- [docker_service_manager_execute](#docker_service_manager_execute): manage docker daemon with Chef -- [docker_service_manager_systemd](#docker_service_manager_systemd): manage docker daemon with systemd unit files -- [docker_image](documentation/docker_image.md): image/repository operations - [docker_container](documentation/docker_container.md): container operations -- [docker_tag](documentation/docker_tag.md): image tagging operations -- [docker_registry](documentation/docker_registry.md): registry operations +- [docker_exec](documentation/docker_exec.md): execute commands inside running containers +- [docker_image](documentation/docker_image.md): image/repository operations +- [docker_image_prune](documentation/docker_image_prune.md): remove unused docker images +- [docker_installation_package](documentation/docker_installation_package.md): install Docker via package 'docker-ce' +- [docker_installation_script](documentation/docker_installation_script.md): install Docker via curl | bash +- [docker_installation_tarball](documentation/docker_installation_tarball.md): install Docker from a tarball - [docker_network](documentation/docker_network.md): network operations -- [docker_volume](documentation/docker_volume.md): volume operations - [docker_plugin](documentation/docker_plugin.md): plugin operations +- [docker_registry](documentation/docker_registry.md): registry operations +- [docker_service_manager_execute](documentation/docker_service_manager_execute.md): manage docker daemon with Chef +- [docker_service_manager_systemd](documentation/docker_service_manager_systemd.md): manage docker daemon with systemd unit files +- [docker_tag](documentation/docker_tag.md): image tagging operations +- [docker_volume](documentation/docker_volume.md): volume operations +- [docker_volume_prune](documentation/docker_volume_prune.md): remove unused docker volumes ## Getting Started diff --git a/documentation/docker_container.md b/documentation/docker_container.md index 08b18efd4..4c4f6c7b3 100644 --- a/documentation/docker_container.md +++ b/documentation/docker_container.md @@ -1,13 +1,13 @@ # docker_container -The `docker_container` is responsible for managing Docker container actions. It speaks directly to the [Docker remote API](https://docs.docker.com/reference/api/docker_remote_api_v1.20/). +The `docker_container` resource is responsible for managing Docker container actions. It speaks directly to the [Docker remote API](https://docs.docker.com/reference/api/docker_remote_api_v1.20/). -Containers are process oriented, and move through an event cycle. +Containers are process oriented and move through an event cycle. ## Actions - `:create` - Creates the container but does not start it. Useful for Volume containers. -- `:start` - Starts the container. Useful for containers that run jobs.. command that exit. +- `:start` - Starts the container. Useful for containers that run jobs and exit. - `:run` - The default action. Both `:create` and `:start` the container in one action. Redeploys the container on resource change. - `:run_if_missing` - Runs a container only once. - `:stop` - Stops the container. @@ -23,82 +23,135 @@ Containers are process oriented, and move through an event cycle. Most `docker_container` properties are the `snake_case` version of the `CamelCase` keys found in the [Docker Remote Api](https://docs.docker.com/reference/api/docker_remote_api_v1.20/) +### Core Properties + - `container_name` - The name of the container. Defaults to the name of the `docker_container` resource. - `repo` - aka `image_name`. The first half of a the complete identifier for a Docker Image. -- `tag` - The second half of a Docker image's identity. - Defaults to `latest`. +- `tag` - The second half of a Docker image's identity. Defaults to `latest`. - `command` - The command to run when starting the container. -- `autoremove` - Boolean - Automatically delete a container when it's command exits. Defaults to `false`. -- `volumes` - An array of volume bindings for this container. Each volume binding is a string in one of these forms: `container_path` to create a new volume for the container. `host_path:container_path` to bind-mount a host path into the container. `host_path:container_path:ro` to make the bind-mount read-only inside the container. -- `cap_add` - An array Linux Capabilities (`man 7 capabilities`) to add to grant the container beyond what it normally gets. -- `cap_drop` - An array Linux Capabilities (`man 7 capabilities`) to revoke that the container normally has. +- `working_dir` - A string specifying the working directory for commands to run in. +- `user` - A string value specifying the user inside the container. + +### Resource Management + - `cpus` - A float or integer value specifying how much of the available CPU resources a container can use. Available in Docker 1.13 and higher. - `cpu_shares` - An integer value containing the CPU Shares for the container. -- `devices` - A Hash of devices to add to the container. -- `dns` - An array of DNS servers the container will use for name resolution. -- `dns_search` - An array of domains the container will search for name resolution. -- `domain_name` - Set's the container's dnsdomainname as returned by the `dnsdomainname` command. -- `entrypoint` - Set the entry point for the container as a string or an array of strings. -- `env` - Set environment variables in the container in the form `['FOO=bar', 'BIZ=baz']` -- `env_file` - Read environment variables from a file and set in the container. Accepts an Array or String to the file location. lazy evaluator must be set if the file passed is created by Chef. -- `extra_hosts` - An array of hosts to add to the container's `/etc/hosts` in the form `['host_a:10.9.8.7', 'host_b:10.9.8.6']` -- `force` - A boolean to use in container operations that support a `force` option. Defaults to `false` -- `gpus` - GPU devices to add to the container. Use 'all' to pass all GPUs to the container. -- `gpu_driver` - GPU driver to use for container. Defaults to 'nvidia'. -- `health_check` - A hash containing the health check options - [healthcheck reference](https://docs.docker.com/engine/reference/run/#healthcheck) -- `host` - A string containing the host the API should communicate with. Defaults to ENV['DOCKER_HOST'] if set -- `host_name` - The hostname for the container. -- `labels` A string, array, or hash to set metadata on the container in the form `['foo:bar', 'hello:world']` -- `links` - An array of source container/alias pairs to link the container to in the form `[container_a:www', container_b:db']` -- `log_driver` - Sets a custom logging driver for the container (json-file/syslog/journald/gelf/fluentd/awslogs/splunk/etwlogs/gcplogs/logentries/loki-docker/local/none). -- `log_opts` - Configures the above logging driver options (driver-specific). -- `init` - Run an init inside the container that forwards signals and reaps processes. -- `ip_address` - Container IPv4 address (e.g. 172.30.100.104) -- `mac_address` - The mac address for the container to use. - `memory` - Memory limit in bytes. -- `memory_swap` - Total memory limit (memory + swap); set `-1` to disable swap limit (unlimited). You must use this with memory and make the swap value larger than memory. +- `memory_swap` - Total memory limit (memory + swap); set `-1` to disable swap limit (unlimited). Must be used with memory and set larger than memory. +- `shm_size` - The size of `/dev/shm`. Format is ``, where number must be greater than 0. Unit is optional: b (bytes), k (kilobytes), m (megabytes), or g (gigabytes). Default is `64m`. + +### Storage and Volumes + +- `volumes` - An array of volume bindings for this container. Each binding can be: + - `container_path` - Creates a new volume for the container + - `host_path:container_path` - Bind-mounts a host path into the container + - `host_path:container_path:ro` - Makes the bind-mount read-only inside the container +- `volumes_from` - A list of volumes to inherit from another container. Format: `[:]` +- `volume_driver` - Driver that this container uses to mount volumes. +- `tmpfs` - A hash or array of tmpfs mounts to add to the container. Provides temporary filesystem without requiring privileged mode. + +### Networking + +- `network_mode` - Sets the networking mode for the container. One of: + - `bridge` - Default Docker bridge network + - `host` - Use the host's network stack inside the container + - `container:` - Use another container's network stack + - `none` - No networking - `network_disabled` - Boolean to disable networking. Defaults to `false`. -- `network_mode` - Sets the networking mode for the container. One of `bridge`, `host`, `container`. - `network_aliases` - Adds network-scoped alias for the container in form `['alias-1', 'alias-2']`. -- `oom_kill_disable` - Whether to disable OOM Killer for the container or not. -- `oom_score_adj` - Tune container's OOM preferences (-1000 to 1000). -- `open_stdin` - Boolean value, opens stdin. Defaults to `false`. -- `outfile` - The path to write the file when using `:export` action. -- `port` - The port configuration to use in the container. Matches the syntax used by the `docker` CLI tool. -- `privileged` - Boolean to start the container in privileged more. Defaults to `false` -- `publish_all_ports` - Allocates a random host port for all of a container's exposed ports. -- `remove_volumes` - A boolean to clean up "dangling" volumes when removing the last container with a reference to it. Default to `false` to match the Docker CLI behavior. -- `restart_policy` - One of `no`, `on-failure`, `unless-stopped`, or `always`. Use `always` if you want a service container to survive a Dockerhost reboot. Defaults to `no`. -- `restart_maximum_retry_count` - Maximum number of restarts to try when `restart_policy` is `on-failure`. Defaults to an ever increasing delay (double the previous delay, starting at 100mS), to prevent flooding the server. -- `running_wait_time` - Amount of seconds `docker_container` wait to determine if a process is running. -- `runtime` - Runtime to use when running container. Defaults to `runc`. +- `hostname` - The hostname for the container. +- `domain_name` - Sets the container's dnsdomainname as returned by the `dnsdomainname` command. +- `dns` - An array of DNS servers the container will use for name resolution. +- `dns_search` - An array of domains the container will search for name resolution. +- `mac_address` - The mac address for the container to use. +- `ip_address` - Container IPv4 address (e.g. 172.30.100.104) + +### Security and Resource Constraints + +- `privileged` - Boolean to start the container in privileged mode. Defaults to `false`. +- `cap_add` - An array Linux Capabilities (`man 7 capabilities`) to add to grant the container beyond what it normally gets. +- `cap_drop` - An array Linux Capabilities (`man 7 capabilities`) to revoke that the container normally has. - `security_opt` - A list of string values to customize labels for MLS systems, such as SELinux. -- `shm_size` - The size of `/dev/shm`. The format is ``, where number must be greater than 0. Unit is optional and can be b (bytes), k (kilobytes), m(megabytes), or g (gigabytes). The default is `64m`. -- `signal` - The signal to send when using the `:kill` action. Defaults to `SIGTERM`. -- `sysctls` - A hash of sysctl settings to configure for the container. -- `timeout` - Timeout setting for container operations. -- `tmpfs` - A hash or array of tmpfs mounts to add to the container. Useful for providing a temporary filesystem without requiring privileged mode. -- `tty` - Boolean value, allocates a pseudo-TTY. Defaults to `false`. -- `user` - A string value specifying the user inside the container. -- `volumes` - An Array of paths inside the container to expose. Does the same thing as the `VOLUME` directive in a Dockerfile, but works on container creation. -- `volumes_from` - A list of volumes to inherit from another container. Specified in the form `[:]` -- `volume_driver` - Driver that this container users to mount volumes. -- `working_dir` - A string specifying the working directory for commands to run in. -- `read_timeout` - May need to increase for commits or exports that are slow -- `write_timeout` - May need to increase for commits or exports that are slow -- `kill_after` - Number of seconds to wait before killing the container. Defaults to wait indefinitely; eventually will hit read_timeout limit. -- `tls` - Use TLS; implied by --tlsverify. Defaults to ENV['DOCKER_TLS'] if set -- `tls_verify` - Use TLS and verify the remote. Defaults to ENV['DOCKER_TLS_VERIFY'] if set -- `tls_ca_cert` - Trust certs signed only by this CA. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_cert` - Path to TLS certificate file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_key` - Path to TLS key file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `userns_mode` - Modify the user namespace mode - Defaults to `nil`, example option: `host` +- `userns_mode` - Modify the user namespace mode. Defaults to `nil`, example option: `host` - `pid_mode` - Set the PID (Process) Namespace mode for the container. `host`: use the host's PID namespace inside the container. -- `ipc_mode` - Set the IPC mode for the container - Defaults to `nil`, example option: `host` -- `uts_mode` - Set the UTS namespace mode for the container. The UTS namespace is for setting the hostname and the domain that is visible to running processes in that namespace. By default, all containers, including those with `--network=host`, have their own UTS namespace. The host setting will result in the container using the same UTS namespace as the host. Note that --hostname is invalid in host UTS mode. -- `ro_rootfs` - Mount the container's root filesystem as read only using the `--read-only` flag. Defaults to `false` +- `ipc_mode` - Set the IPC mode for the container. Defaults to `nil`, example option: `host` +- `uts_mode` - Set the UTS namespace mode for the container. +- `ro_rootfs` - Mount the container's root filesystem as read only. Defaults to `false` + +### Logging Properties + +- `log_driver` - The logging driver to use for the container. One of: + - `json-file` - Default Docker logging driver that writes JSON messages to file + - `syslog` - Syslog logging driver that writes log messages to syslog + - `journald` - Journald logging driver that writes log messages to systemd journal + - `gelf` - Graylog Extended Log Format (GELF) logging driver + - `fluentd` - Fluentd logging driver + - `awslogs` - Amazon CloudWatch Logs logging driver + - `splunk` - Splunk logging driver + - `etwlogs` - ETW logging driver for Windows + - `gcplogs` - Google Cloud Logging driver + - `logentries` - Logentries logging driver + - `loki-docker` - Grafana Loki logging driver + - `none` - Disables container logging + - `local` - Local file-based logging driver + Defaults to `json-file`. + +- `log_opts` - A hash of key-value pairs to configure the selected log driver. Common options include: + - For json-file: + - `max-size` - Maximum size of the log before it is rolled + - `max-file` - Maximum number of log files that can exist + - For syslog: + - `syslog-address` - Address of remote syslog server + - `tag` - Tag for syslog messages + - For other drivers, refer to the [Docker logging configuration documentation](https://docs.docker.com/config/containers/logging/configure/) + +### GPU Support + +- `gpus` - GPU devices to add to the container. Use 'all' to pass all GPUs. +- `gpu_driver` - GPU driver to use. Defaults to 'nvidia'. ## Examples +### Basic Container Creation + +```ruby +docker_container 'hello-world' do + command '/hello' + action :create +end +``` + +### Using tmpfs Mounts + +```ruby +# Using hash format with mount options +docker_container 'tmpfs_test' do + repo 'nginx' + tmpfs({ + '/tmpfs1' => '', # No options + '/tmpfs2' => 'size=20M,uid=1000', # With size and uid options + '/tmpfs3' => 'rw,noexec,nosuid,size=50M' # With multiple options + }) +end + +# Using array format (all mounts will have default options) +docker_container 'tmpfs_test' do + repo 'nginx' + tmpfs ['/tmpfs1', '/tmpfs2'] +end +``` + +### Container with GPU Support + +```ruby +docker_container 'gpu_container' do + repo 'nvidia/cuda' + tag 'latest' + gpus 'all' # Pass all GPUs to the container + gpu_driver 'nvidia' # Use NVIDIA driver +end +``` + ### Create a container without starting it ```ruby @@ -564,3 +617,30 @@ docker_container 'custom_gpu_container' do gpu_driver 'custom_driver' action :run_if_missing end + +``` + +### Using json-file driver with size limits + +```ruby +docker_container 'webapp' do + repo 'nginx' + log_driver 'json-file' + log_opts({ + 'max-size' => '10m', + 'max-file' => '3' + }) +end +``` + +### Using syslog driver with remote server + +```ruby +docker_container 'webapp' do + repo 'nginx' + log_driver 'syslog' + log_opts({ + 'syslog-address' => 'udp://1.2.3.4:1111', + 'tag' => 'webapp' + }) +end diff --git a/documentation/docker_exec.md b/documentation/docker_exec.md index 1bc06cfaf..e766e5a61 100644 --- a/documentation/docker_exec.md +++ b/documentation/docker_exec.md @@ -1,24 +1,77 @@ # docker_exec -The `docker_exec` resource allows you to execute commands inside of a running container. +The `docker_exec` resource allows you to execute commands inside of a running container. This is equivalent to using the `docker exec` command and is useful for running commands, scripts, or interactive shells within containers. ## Actions -- `:run` - Runs the command +- `:run` - Executes the specified command inside the container ## Properties -- `host` - Daemon socket(s) to connect to - `tcp://host:port`, `unix:///path/to/socket`, `fd://*` or `fd://socketfd`. -- `command` - A command structured as an Array similar to `CMD` in a Dockerfile. -- `container` - Name of the container to execute the command in. -- `timeout`- Seconds to wait for an attached container to return. Defaults to 60 seconds. -- `container_obj` +### Required Properties + +- `container` - Name or ID of the container to execute the command in +- `command` - Command to execute, structured as an Array similar to `CMD` in a Dockerfile (alias: `cmd`) + +### Optional Properties + +- `host` - Docker daemon socket to connect to (default: ENV['DOCKER_HOST']) +- `timeout` - Seconds to wait for the command to complete (default: 60) +- `returns` - Expected return value(s) for the command (default: [0]). Can be a single integer or array of accepted values. ## Examples +### Basic Command Execution + +```ruby +docker_exec 'create_file' do + container 'web_app' + command ['touch', '/tmp/test_file'] +end +``` + +### Custom Return Values + ```ruby -docker_exec 'touch_it' do - container 'busybox_exec' - command ['touch', '/tmp/onefile'] +docker_exec 'check_status' do + container 'app' + command ['grep', 'pattern', '/var/log/app.log'] + returns [0, 1] # Accept both found (0) and not-found (1) as valid returns end ``` + +### Long Running Commands + +```ruby +docker_exec 'database_backup' do + container 'database' + command ['pg_dump', '-U', 'postgres', 'mydb', '>', '/backup/db.sql'] + timeout 300 # 5 minutes timeout for backup +end +``` + +### Multiple Commands with Shell + +```ruby +docker_exec 'setup_environment' do + container 'web_app' + command ['sh', '-c', 'mkdir -p /app/data && chown www-data:www-data /app/data'] +end +``` + +## Notes + +1. The container must be running when executing commands +2. The `command` property must be an array where each argument is a separate element +3. Use `sh -c` when you need to use shell features like pipes or environment variables +4. Set appropriate timeouts for long-running commands +5. Use the `returns` property to handle commands that may have multiple valid exit codes + +## Common Use Cases + +- Running database migrations +- Installing system packages +- Modifying configuration files +- Running maintenance tasks +- Health checks +- Log inspection diff --git a/documentation/docker_installation_package.md b/documentation/docker_installation_package.md new file mode 100644 index 000000000..fefd457fe --- /dev/null +++ b/documentation/docker_installation_package.md @@ -0,0 +1,94 @@ +# docker_installation_package + +The `docker_installation_package` resource is responsible for installing Docker via package manager. It supports both Debian/Ubuntu and RHEL/Fedora platforms. + +## Actions + +- `:create` - Installs Docker package and sets up the Docker repository if enabled +- `:delete` - Removes the Docker package + +## Properties + +| Property | Type | Default | Description | +|------------------|---------|------------------------|------------------------------------------------------------| +| `setup_docker_repo` | Boolean | `true` | Whether to set up the Docker repository | +| `repo_channel` | String | `'stable'` | Repository channel to use (`stable`, `test`, `nightly`) | +| `package_name` | String | `'docker-ce'` | Name of the Docker package to install | +| `package_version` | String | `nil` | Specific package version to install | +| `version` | String | `nil` | Docker version to install (e.g., '20.10.23') | +| `package_options` | String | `nil` | Additional options to pass to the package manager | +| `site_url` | String | `'download.docker.com'`| Docker repository URL | + +## Examples + +### Install Latest Version of Docker + +```ruby +docker_installation_package 'default' do + action :create +end +``` + +### Install Specific Version of Docker + +```ruby +docker_installation_package 'default' do + version '20.10.23' + action :create +end +``` + +### Install from Test Channel + +```ruby +docker_installation_package 'default' do + repo_channel 'test' + action :create +end +``` + +### Install Without Setting Up Docker Repository + +```ruby +docker_installation_package 'default' do + setup_docker_repo false + action :create +end +``` + +### Remove Docker Installation + +```ruby +docker_installation_package 'default' do + action :delete +end +``` + +## Platform Support + +This resource supports the following platforms: + +### Debian/Ubuntu + +- Debian 9 (Stretch) +- Debian 10 (Buster) +- Debian 11 (Bullseye) +- Debian 12 (Bookworm) +- Ubuntu 18.04 (Bionic) +- Ubuntu 20.04 (Focal) +- Ubuntu 22.04 (Jammy) +- Ubuntu 24.04 (Noble) + +### RHEL/Fedora + +- RHEL/CentOS 7 and later +- Fedora (latest versions) + +## Notes + +- The resource automatically handles architecture-specific package names and repositories +- For Debian/Ubuntu systems, it installs `apt-transport-https` package as a prerequisite +- Version strings are handled differently based on the Docker version and platform: + - For versions < 18.06: Uses format like `VERSION~ce-0~debian` or `VERSION~ce-0~ubuntu` + - For versions >= 18.09: Uses format like `5:VERSION~3-0~debian-CODENAME` or `5:VERSION~3-0~ubuntu-CODENAME` + - For versions >= 23.0 on Ubuntu: Uses format like `5:VERSION-1~ubuntu.VERSION~CODENAME` diff --git a/documentation/docker_installation_script.md b/documentation/docker_installation_script.md new file mode 100644 index 000000000..e0d581c04 --- /dev/null +++ b/documentation/docker_installation_script.md @@ -0,0 +1,75 @@ +# docker_installation_script + +The `docker_installation_script` resource installs Docker on Linux systems using the official Docker installation scripts. This is also known as the "curl pipe bash" installation method. + +## Actions + +- `:create` - Downloads and executes the Docker installation script +- `:delete` - Removes Docker packages installed by the script + +## Properties + +| Property | Type | Default | Description | +|-------------|--------|----------------|-----------------------------------------------------------------------| +| `repo` | String | `'main'` | Repository to use for installation. One of: `main`, `test`, or `experimental` | +| `script_url`| String | Based on repo | URL of the installation script. Defaults to official Docker URLs based on the repo property | + +## Examples + +### Install Docker from Main Repository + +```ruby +docker_installation_script 'default' do + action :create +end +``` + +### Install Docker from Test Repository + +```ruby +docker_installation_script 'default' do + repo 'test' + action :create +end +``` + +### Install Docker from Experimental Repository + +```ruby +docker_installation_script 'default' do + repo 'experimental' + action :create +end +``` + +### Install Docker Using Custom Script URL + +```ruby +docker_installation_script 'default' do + script_url 'https://my-custom-docker-install.example.com/install.sh' + action :create +end +``` + +### Remove Docker Installation + +```ruby +docker_installation_script 'default' do + action :delete +end +``` + +## Notes + +- This resource is only available on Linux systems +- The installation script requires `curl` to be installed (the resource will install it if missing) +- The script is executed with `sh` shell +- The installation is considered complete when `/usr/bin/docker` exists +- When removing Docker, both `docker-ce` and `docker-engine` packages are removed +- Default script URLs: + - Main: + - Test: + +## Platform Support + +This resource is supported on all Linux platforms that can run the Docker installation scripts. diff --git a/documentation/docker_installation_tarball.md b/documentation/docker_installation_tarball.md new file mode 100644 index 000000000..1827f1c8f --- /dev/null +++ b/documentation/docker_installation_tarball.md @@ -0,0 +1,84 @@ +# docker_installation_tarball + +The `docker_installation_tarball` resource installs Docker on a system using pre-compiled binary tarballs from the official Docker downloads. + +## Actions + +- `:create` - Downloads and installs Docker from a tarball +- `:delete` - Removes Docker installed from a tarball + +## Properties + +| Property | Type | Default | Description | +|------------|--------|-------------------|--------------------------------------------| +| `checksum` | String | Based on version | SHA256 checksum of the Docker tarball | +| `source` | String | Based on version | URL of the Docker tarball | +| `channel` | String | `'stable'` | Docker release channel to use | +| `version` | String | `'20.10.11'` | Docker version to install | + +## Examples + +### Install Default Version + +```ruby +docker_installation_tarball 'default' do + action :create +end +``` + +### Install Specific Version + +```ruby +docker_installation_tarball 'default' do + version '19.03.15' + action :create +end +``` + +### Install from Custom Source + +```ruby +docker_installation_tarball 'default' do + source 'https://example.com/docker-20.10.11.tgz' + checksum 'dd6ff72df1edfd61ae55feaa4aadb88634161f0aa06dbaaf291d1be594099ff3' + action :create +end +``` + +### Remove Docker Installation + +```ruby +docker_installation_tarball 'default' do + action :delete +end +``` + +## Platform Support + +This resource supports the following platforms: + +### Linux + +- Version 18.03.1: checksum `0e245c42de8a21799ab11179a4fce43b494ce173a8a2d6567ea6825d6c5265aa` +- Version 18.06.3: checksum `346f9394393ee8db5f8bd1e229ee9d90e5b36931bdd754308b2ae68884dd6822` +- Version 18.09.9: checksum `82a362af7689038c51573e0fd0554da8703f0d06f4dfe95dd5bda5acf0ae45fb` +- Version 19.03.15: checksum `5504d190eef37355231325c176686d51ade6e0cabe2da526d561a38d8611506f` +- Version 20.10.11: checksum `dd6ff72df1edfd61ae55feaa4aadb88634161f0aa06dbaaf291d1be594099ff3` + +### Darwin (macOS) + +- Version 18.03.1: checksum `bbfb9c599a4fdb45523496c2ead191056ff43d6be90cf0e348421dd56bc3dcf0` +- Version 18.06.3: checksum `f7347ef27db9a438b05b8f82cd4c017af5693fe26202d9b3babf750df3e05e0c` +- Version 18.09.9: checksum `ed83a3d51fef2bbcdb19d091ff0690a233aed4bbb47d2f7860d377196e0143a0` +- Version 19.03.15: checksum `61672045675798b2075d4790665b74336c03b6d6084036ef22720af60614e50d` +- Version 20.10.11: checksum `8f338ba618438fa186d1fa4eae32376cca58f86df2b40b5027c193202fad2acf` + +## Notes + +- The resource automatically detects the system architecture and kernel type to download the appropriate tarball +- Requires `tar` package to be installed (the resource will install it if missing) +- Creates a `docker` system group +- Filename format varies based on Docker version: + - For versions >= 19.x.x: `docker-VERSION.tgz` + - For version 18.09.x: `docker-VERSION.tgz` + - For versions <= 18.06.x: `docker-VERSION-ce.tgz` diff --git a/documentation/docker_service.md b/documentation/docker_service.md index b9fe33904..2a33814fb 100644 --- a/documentation/docker_service.md +++ b/documentation/docker_service.md @@ -1,117 +1,187 @@ # docker_service -The `docker_service`: resource is a composite resource that uses `docker_installation` and `docker_service_manager` resources. +The `docker_service` resource is a composite resource that manages Docker daemon installation and service configuration. It combines the functionality of `docker_installation` and `docker_service_manager` resources. -- The `:create` action uses a `docker_installation` -- The `:delete` action uses a `docker_installation` -- The `:start` action uses a `docker_service_manager` -- The `:stop` action uses a `docker_service_manager` +## Actions -The service management strategy for the host platform is dynamically chosen based on platform, but can be overridden. +- `:create` - Installs Docker using `docker_installation` +- `:delete` - Removes Docker installation +- `:start` - Starts the Docker daemon using `docker_service_manager` +- `:stop` - Stops the Docker daemon +- `:restart` - Restarts the Docker daemon -## Example +The service management strategy is automatically chosen based on the platform but can be overridden. -```ruby -docker_service 'tls_test:2376' do - host [ "tcp://#{node['ipaddress']}:2376", 'unix:///var/run/docker.sock' ] - tls_verify true - tls_ca_cert '/path/to/ca.pem' - tls_server_cert '/path/to/server.pem' - tls_server_key '/path/to/server-key.pem' - tls_client_cert '/path/to/client.pem' - tls_client_key '/path/to/client-key.pem' - action [:create, :start] -end -``` +## Properties -WARNING - When creating multiple `docker_service` resources on the same machine, you will need to specify unique data_root properties to avoid unexpected behavior and possible data corruption. +### Installation Properties -## Properties +- `install_method` - Installation method: `script`, `package`, `tarball`, `none`, or `auto` (default) +- `service_manager` - Service manager to use: `execute`, `systemd`, `none`, or `auto` (default) -The `docker_service` resource property list mostly corresponds to the options found in the [Docker Command Line Reference](https://docs.docker.com/engine/reference/commandline/docker/) - -- `api_cors_header` - Set CORS headers in the remote API -- `auto_restart` -- `exec_opts` -- `bip` - Specify network bridge IP -- `bridge` - Attach containers to a network bridge -- `checksum` - sha256 checksum of Docker binary -- `cluster_advertise` - IP and port that this daemon should advertise to the cluster -- `cluster_store_opts` - Cluster store options -- `cluster_store` - Cluster store to use -- `daemon` - Enable daemon mode -- `data_root` - Root of the Docker runtime -- `debug` - Enable debug mode -- `default_ip_address_pool` - Set the default address pool for networks creates by docker -- `default_ulimit` - Set default ulimit settings for containers -- `disable_legacy_registry` - Do not contact legacy registries -- `dns_search` - DNS search domains to use -- `dns` - DNS server(s) to use -- `exec_driver` - Exec driver to use -- `fixed_cidr_v6` - IPv6 subnet for fixed IPs +#### Script Installation + +- `repo` - Repository URL for script installation +- `script_url` - Custom script URL for installation + +#### Package Installation + +- `package_version` - Specific package version to install +- `package_name` - Package name (default: docker-ce) +- `setup_docker_repo` - Whether to configure Docker repository +- `package_options` - Additional package installation options + +#### Tarball Installation + +- `checksum` - SHA256 checksum of Docker binary +- `docker_bin` - Path to Docker binary +- `source` - URL to Docker binary tarball +- `version` - Docker version to install + +### Core Settings + +- `instance` - Resource name (name property) +- `env_vars` - Hash of environment variables for Docker service +- `data_root` - Root directory of the Docker runtime +- `debug` - Enable debug mode (default: false) +- `daemon` - Enable daemon mode (default: true) +- `group` - Posix group for unix socket (default: 'docker') + +### Network Configuration + +- `bip` - Network bridge IP (accepts IPv4/IPv6 address/CIDR) +- `bridge` - Network bridge for container attachment +- `default_ip_address_pool` - Default address pool for networks +- `dns` - DNS servers (String or Array) +- `dns_search` - DNS search domains (Array) - `fixed_cidr` - IPv4 subnet for fixed IPs -- `group` - Posix group for the unix socket. Default to `docker` -- `host` - Daemon socket(s) to connect to - `tcp://host:port`, `unix:///path/to/socket`, `fd://*` or `fd://socketfd` -- `http_proxy` - ENV variable set before for Docker daemon starts -- `https_proxy` - ENV variable set before for Docker daemon starts -- `icc` - Enable inter-container communication -- `insecure_registry` - Enable insecure registry communication -- `install_method` - Select script, package, tarball, none, or auto. Defaults to `auto`. -- `instance`- Optional property used to override the name provided in the resource. -- `ip_forward` - Enable ip forwarding +- `fixed_cidr_v6` - IPv6 subnet for fixed IPs +- `ip` - Default IP for container binding (IPv4/IPv6) +- `ip_forward` - Enable IP forwarding +- `ipv4_forward` - Enable net.ipv4.ip_forward (default: true) +- `ipv6_forward` - Enable net.ipv6.ip_forward (default: true) - `ip_masq` - Enable IP masquerading -- `ip` - Default IP when binding container ports -- `iptables` - Enable addition of iptables rules -- `ip6tables` - Enable addition of ip6tables rules -- `ipv4_forward` - Enable net.ipv4.ip_forward -- `ipv6_forward` - Enable net.ipv6.ip_forward +- `iptables` - Enable iptables rules +- `ip6tables` - Enable ip6tables rules - `ipv6` - Enable IPv6 networking -- `labels` A string or array to set metadata on the daemon in the form ['foo:bar', 'hello:world']` -- `log_driver` - Container's logging driver (json-file/syslog/journald/gelf/fluentd/awslogs/splunk/etwlogs/gcplogs/logentries/loki-docker/local/none) -- `log_level` - Set the logging level -- `log_opts` - Container's logging driver options (driver-specific) -- `logfile` - Location of Docker daemon log file -- `mount_flags` - Set the systemd mount propagation flag. -- `mtu` - Set the containers network MTU -- `no_proxy` - ENV variable set before for Docker daemon starts -- `package_name` - Set the package name. Defaults to `docker-ce` -- `pidfile` - Path to use for daemon PID file -- `registry_mirror` - A string or array to set the preferred Docker registry mirror(s) -- `selinux_enabled` - Enable selinux support -- `source` - URL to the pre-compiled Docker binary used for installation. Defaults to a calculated URL based on kernel version, Docker version, and platform arch. By default, this will try to get to "". -- `storage_driver` - Storage driver to use -- `storage_opts` - Set storage driver options -- `tls_ca_cert` - Trust certs signed only by this CA. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_cert` - Path to TLS certificate file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_client_key` - Path to TLS key file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if set -- `tls_server_cert` - Path to TLS certificate file for docker service -- `tls_server_key` - Path to TLS key file for docker service -- `tls_verify` - Use TLS and verify the remote. Defaults to ENV['DOCKER_TLS_VERIFY'] if set -- `tls` - Use TLS; implied by --tlsverify. Defaults to ENV['DOCKER_TLS'] if set -- `tmpdir` - ENV variable set before for Docker daemon starts -- `userland_proxy`- Enables or disables docker-proxy -- `userns_remap` - Enable user namespace remapping options - `default`, `uid`, `uid:gid`, `username`, `username:groupname` (see: [Docker User Namespaces](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-user-namespace-options)) -- `live_restore` - Keep containers alive during daemon downtime (see: [Live restore](https://docs.docker.com/config/containers/live-restore)) -- `version` - Docker version to install +- `mtu` - Container network MTU -### Miscellaneous Options +### Cluster Configuration -- `misc_opts` - Pass the docker daemon any other options bypassing flag validation, supplied as `--flag=value` +- `cluster_store` - Cluster store settings +- `cluster_advertise` - Cluster advertisement configuration +- `cluster_store_opts` - Cluster store options (String or Array) -### Systemd-specific Options +### API and Security -- `systemd_opts` - An array of strings that will be included as individual lines in the systemd service unit for Docker. _Note_: This option is only relevant for systems where systemd is the default service manager or where systemd is specified explicitly as the service manager. -- `systemd_socket_opts` - An array of strings that will be included as individual lines in the systemd socket unit for Docker. _Note_: This option is only relevant for systems where systemd is the default service manager or where systemd is specified explicitly as the service manager. +- `api_cors_header` - Set CORS headers for remote API +- `host` - Docker daemon socket(s) to connect to +- `selinux_enabled` - Enable SELinux support +- `userns_remap` - User namespace remapping options +- `labels` - Daemon metadata (String or Array) -## Actions +### Storage + +- `storage_driver` - Storage driver (String or Array) +- `storage_opts` - Storage driver options (Array) +- `exec_driver` - Execution driver ('native', 'lxc', nil) +- `exec_opts` - Execution options (String or Array) + +### Logging + +- `log_driver` - Container logging driver: + - Supported: json-file, syslog, journald, gelf, fluentd, awslogs, splunk, etwlogs, gcplogs, logentries, loki-docker, none, local +- `log_opts` - Logging driver options (String or Array) +- `log_level` - Logging level (debug, info, warn, error, fatal) +- `logfile` - Log file location (default: '/var/log/docker.log') + +### Process Management + +- `pidfile` - PID file location (default: /var/run/[service-name].pid) +- `auto_restart` - Enable automatic restart (default: false) +- `service_timeout` - Docker wait-ready timeout in seconds (default: 20) + +### Proxy Settings + +- `http_proxy` - HTTP proxy environment variable +- `https_proxy` - HTTPS proxy environment variable +- `no_proxy` - No proxy environment variable +- `tmpdir` - Temporary directory path + +### Registry + +- `disable_legacy_registry` - Disable legacy registry support +- `insecure_registry` - Enable insecure registry communication +- `registry_mirror` - Preferred registry mirror(s) + +### Resource Limits -- `:create` - Lays the Docker bits out on disk -- `:delete` - Removes the Docker bits from the disk -- `:start` - Makes sure the service provider is set up properly and start it -- `:stop` - Stops the service -- `:restart` - Restarts the service +- `default_ulimit` - Default ulimit settings (String or Array) + +### Service Management + +#### Systemd Options + +- `systemd_opts` - Additional systemd service unit options +- `systemd_socket_opts` - Additional systemd socket unit options +- `mount_flags` - Systemd mount propagation flags + +### Advanced Options + +- `live_restore` - Keep containers alive during daemon downtime (default: false) +- `userland_proxy` - Enable/disable docker-proxy +- `misc_opts` - Additional daemon options as `--flag=value` + +## Examples + +### Basic Docker Service + +```ruby +docker_service 'default' do + action [:create, :start] +end +``` + +### Custom Installation + +```ruby +docker_service 'custom' do + install_method 'package' + package_version '20.10.11' + service_manager 'systemd' + action [:create, :start] +end +``` + +### Secure Configuration with Registry Mirrors + +```ruby +docker_service 'production' do + registry_mirror ['https://mirror1.example.com', 'https://mirror2.example.com'] + insecure_registry ['172.16.0.0/12'] + storage_driver 'overlay2' + storage_opts ['overlay2.override_kernel_check=true'] + log_driver 'json-file' + log_opts ['max-size=100m', 'max-file=3'] + action [:create, :start] +end +``` + +### Multiple Services + +```ruby +docker_service 'primary' do + data_root '/var/lib/docker-primary' + action [:create, :start] +end + +docker_service 'secondary' do + data_root '/var/lib/docker-secondary' + host ['tcp://0.0.0.0:2375'] + action [:create, :start] +end +``` -## `docker_service` implementations +## Warning -- `docker_service_execute` - The simplest docker_service. Just starts a process. Fire and forget. -- `docker_service_systemd` - Uses an Systemd unit file to manage the service state. NOTE: This does NOT enable systemd socket activation. +When creating multiple `docker_service` resources on the same machine, you MUST specify unique `data_root` properties to avoid data corruption and unexpected behavior. diff --git a/documentation/docker_service_manager_execute.md b/documentation/docker_service_manager_execute.md new file mode 100644 index 000000000..bba7b4731 --- /dev/null +++ b/documentation/docker_service_manager_execute.md @@ -0,0 +1,74 @@ +# docker_service_manager_execute + +The `docker_service_manager_execute` resource manages the Docker daemon using Chef's execute resources. This is a basic service manager that uses shell commands to start, stop, and restart the Docker daemon. + +## Actions + +- `:start` - Starts the Docker daemon +- `:stop` - Stops the Docker daemon +- `:restart` - Restarts the Docker daemon (stop followed by start) + +## Properties + +This resource inherits properties from the `docker_service_base` resource. Common properties include: + +| Property | Type | Default | Description | +|-------------------|--------|------------|------------------------------------------------| +| `docker_daemon_cmd`| String | Generated | Command to start the Docker daemon | +| `logfile` | String | Based on name | Path to the log file | +| `pidfile` | String | Based on name | Path to the PID file | +| `http_proxy` | String | `nil` | HTTP proxy settings | +| `https_proxy` | String | `nil` | HTTPS proxy settings | +| `no_proxy` | String | `nil` | No proxy settings | +| `tmpdir` | String | `nil` | Temporary directory path | + +## Examples + +### Basic Usage + +```ruby +docker_service_manager_execute 'default' do + action :start +end +``` + +### Start Docker with Custom Settings + +```ruby +docker_service_manager_execute 'default' do + http_proxy 'http://proxy.example.com:3128' + https_proxy 'http://proxy.example.com:3128' + no_proxy 'localhost,127.0.0.1' + action :start +end +``` + +### Stop Docker Service + +```ruby +docker_service_manager_execute 'default' do + action :stop +end +``` + +### Restart Docker Service + +```ruby +docker_service_manager_execute 'default' do + action :restart +end +``` + +## Notes + +- This resource enables IPv4 and IPv6 forwarding using sysctl +- The Docker daemon is started as a background process using bash +- A wait script is created to ensure the daemon is ready before proceeding +- The stop action uses a timeout of 10 seconds when stopping the daemon +- The resource uses process checking to prevent duplicate daemon instances +- Log output is redirected to the specified logfile +- Environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY, TMPDIR) are passed to the daemon process + +## Platform Support + +This resource should work on any platform that can run the Docker daemon, but it's primarily tested on Linux systems. diff --git a/documentation/docker_service_manager_systemd.md b/documentation/docker_service_manager_systemd.md new file mode 100644 index 000000000..d041620ab --- /dev/null +++ b/documentation/docker_service_manager_systemd.md @@ -0,0 +1,98 @@ +# docker_service_manager_systemd + +The `docker_service_manager_systemd` resource manages the Docker daemon using systemd. This is the preferred way to manage Docker on systems that use systemd as their init system. + +## Actions + +- `:start` - Starts and enables the Docker daemon +- `:stop` - Stops and disables the Docker daemon +- `:restart` - Restarts the Docker daemon (stop followed by start) + +## Properties + +This resource inherits properties from the `docker_service_base` resource. Common properties include: + +| Property | Type | Default | Description | +|-------------------|---------|------------|--------------------------------------------------| +| `docker_daemon_cmd`| String | Generated | Command to start the Docker daemon | +| `docker_name` | String | `'docker'` | Name of the Docker service | +| `connect_socket` | String | `nil` | Docker socket path | +| `docker_containerd`| Boolean | - | Whether to use containerd | +| `env_vars` | Hash | `{}` | Environment variables for the Docker daemon | +| `systemd_socket_args`| Hash | `{}` | Additional systemd socket arguments | +| `systemd_args` | Hash | `{}` | Additional systemd service arguments | + +## Examples + +### Basic Usage + +```ruby +docker_service_manager_systemd 'default' do + action :start +end +``` + +### Custom Service Configuration + +```ruby +docker_service_manager_systemd 'default' do + systemd_args({ + 'TimeoutStartSec' => '0', + 'ExecStartPost' => '/usr/bin/sleep 1' + }) + env_vars({ + 'HTTP_PROXY' => 'http://proxy.example.com:3128', + 'NO_PROXY' => 'localhost,127.0.0.1' + }) + action :start +end +``` + +### Using Custom Socket + +```ruby +docker_service_manager_systemd 'default' do + connect_socket 'unix:///var/run/custom-docker.sock' + action :start +end +``` + +### Stop Docker Service + +```ruby +docker_service_manager_systemd 'default' do + action :stop +end +``` + +## Files Created/Modified + +The resource manages the following files: + +- `/lib/systemd/system/[docker_name].socket` - Main systemd socket file +- `/etc/systemd/system/[docker_name].socket` - Socket override file +- `/lib/systemd/system/[docker_name].service` - Main systemd service file +- `/etc/systemd/system/[docker_name].service` - Service override file +- `/etc/containerd/config.toml` - Containerd configuration +- `/etc/systemd/system/containerd.service` - Containerd service file (if enabled) + +## Notes + +- This resource is only available on Linux systems using systemd +- Automatically creates and manages containerd configuration when needed +- Supports both socket activation and direct service management +- Handles systemd daemon-reload automatically when configurations change +- Includes retry logic for service start operations +- Creates a wait-ready script to ensure Docker is fully operational +- Supports custom environment variables and systemd unit options +- Can be used with custom Docker socket paths +- Manages both the Docker service and its associated socket unit + +## Platform Support + +This resource is supported on Linux distributions that use systemd as their init system, including: + +- Recent versions of Ubuntu (16.04+) +- Recent versions of Debian (8+) +- Recent versions of CentOS/RHEL (7+) +- Recent versions of Fedora diff --git a/documentation/docker_volume_prune.md b/documentation/docker_volume_prune.md new file mode 100644 index 000000000..2db73210e --- /dev/null +++ b/documentation/docker_volume_prune.md @@ -0,0 +1,76 @@ +# docker_volume_prune + +The `docker_volume_prune` resource removes all unused Docker volumes. Volumes that are still referenced by at least one container are not removed. + +## Actions + +- `:prune` - Remove unused Docker volumes + +## Properties + +| Property | Type | Default | Description | +|-----------------|---------|----------------------|---------------------------------------------------| +| `without_label` | String | `nil` | Only remove volumes without the specified label | +| `with_label` | String | `nil` | Only remove volumes with the specified label | +| `read_timeout` | Integer | `120` | HTTP read timeout for Docker API calls | +| `host` | String | `ENV['DOCKER_HOST']` | Docker daemon socket to connect to | +| `all` | Boolean | `false` | Remove all unused volumes, not just dangling ones | + +## Examples + +### Basic Usage - Remove Unused Volumes + +```ruby +docker_volume_prune 'prune' do + action :prune +end +``` + +### Remove All Unused Volumes + +```ruby +docker_volume_prune 'prune_all' do + all true + action :prune +end +``` + +### Remove Volumes with Specific Label + +```ruby +docker_volume_prune 'prune_labeled' do + with_label 'environment=test' + action :prune +end +``` + +### Remove Volumes Without Specific Label + +```ruby +docker_volume_prune 'prune_without_label' do + without_label 'environment=production' + action :prune +end +``` + +### Custom Docker Host + +```ruby +docker_volume_prune 'prune' do + host 'tcp://127.0.0.1:2375' + action :prune +end +``` + +## Notes + +- Uses Docker Engine API v1.42 +- The prune operation removes all unused volumes that are not referenced by any containers +- The operation is irreversible - once a volume is pruned, its data cannot be recovered +- The resource logs the result of the prune operation +- The `read_timeout` property can be adjusted if the operation takes longer than expected +- Label filters can be used to selectively prune volumes based on their metadata + +## Platform Support + +This resource is supported on any platform that can run the Docker daemon. diff --git a/resources/installation_script.rb b/resources/installation_script.rb index b794a48c8..a9c9ee069 100644 --- a/resources/installation_script.rb +++ b/resources/installation_script.rb @@ -16,14 +16,7 @@ ######################### def default_script_url - case repo - when 'main' - 'https://get.docker.com/' - when 'test' - 'https://test.docker.com/' - when 'experimental' - 'https://experimental.docker.com/' - end + "https://#{repo == 'main' ? 'get' : 'test'}.docker.com/" end #########