docker_service
May 27, 2026 ยท View on GitHub
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.
Actions
:create- Installs Docker usingdocker_installation:delete- Removes Docker installation:start- Starts the Docker daemon usingdocker_service_manager:stop- Stops the Docker daemon:restart- Restarts the Docker daemon
The service management strategy is automatically chosen based on the platform but can be overridden.
Properties
Installation Properties
install_method- Installation method:script,package,tarball,none, orauto(default)service_manager- Service manager to use:execute,systemd,none, orauto(default)
Script Installation
repo- Repository URL for script installationscript_url- Custom script URL for installation
Package Installation
package_version- Specific package version to installpackage_name- Package name (default: docker-ce)setup_docker_repo- Whether to configure Docker repositorypackage_options- Additional package installation options
Tarball Installation
checksum- SHA256 checksum of Docker binarydocker_bin- Path to Docker binarysource- URL to Docker binary tarballversion- Docker version to install
Core Settings
instance- Resource name (name property)env_vars- Hash of environment variables for Docker servicedata_root- Root directory of the Docker runtimedebug- 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 attachmentdefault_ip_address_pool- Default address pool for networksdns- DNS servers (String or Array)dns_search- DNS search domains (Array)fixed_cidr- IPv4 subnet for fixed IPsfixed_cidr_v6- IPv6 subnet for fixed IPsip- Default IP for container binding (IPv4/IPv6)ip_forward- Enable IP forwardingipv4_forward- Enable net.ipv4.ip_forward (default: true)ipv6_forward- Enable net.ipv6.ip_forward (default: true)ip_masq- Enable IP masqueradingiptables- Enable iptables rulesip6tables- Enable ip6tables rulesipv6- Enable IPv6 networkingmtu- Container network MTU
Cluster Configuration
cluster_store- Cluster store settingscluster_advertise- Cluster advertisement configurationcluster_store_opts- Cluster store options (String or Array)
Docker Engine 23.0 removed the classic cluster store daemon flags. These properties are ignored when the installed Docker version is 23.0 or later.
API and Security
api_cors_header- Set CORS headers for remote APIhost- Docker daemon socket(s) to connect toselinux_enabled- Enable SELinux supportuserns_remap- User namespace remapping optionslabels- Daemon metadata (String or Array)
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 variablehttps_proxy- HTTPS proxy environment variableno_proxy- No proxy environment variabletmpdir- Temporary directory path
Registry
disable_legacy_registry- Disable legacy registry supportinsecure_registry- Enable insecure registry communicationregistry_mirror- Preferred registry mirror(s)
Resource Limits
default_ulimit- Default ulimit settings (String or Array)
Service Management
Systemd Options
systemd_opts- Additional systemd service unit optionssystemd_socket_opts- Additional systemd socket unit optionsmount_flags- Systemd mount propagation flags
Advanced Options
live_restore- Keep containers alive during daemon downtime (default: false)userland_proxy- Enable/disable docker-proxymisc_opts- Additional daemon options as--flag=value
Examples
Basic Docker Service
docker_service 'default' do
action [:create, :start]
end
Custom Installation
docker_service 'custom' do
install_method 'package'
package_version '20.10.11'
service_manager 'systemd'
action [:create, :start]
end
Secure Configuration with Registry Mirrors
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
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
Warning
When creating multiple docker_service resources on the same machine, you MUST specify unique data_root properties to avoid data corruption and unexpected behavior.