docker_service
The docker_service: resource is a composite resource that uses docker_installation and docker_service_manager resources.
- The
:createaction uses adocker_installation - The
:deleteaction uses adocker_installation - The
:startaction uses adocker_service_manager - The
:stopaction uses adocker_service_manager
The service management strategy for the host platform is dynamically chosen based on platform, but can be overridden.
Example
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]
endWARNING - 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.
Properties
The docker_service resource property list mostly corresponds to the options found in the Docker Command Line Reference (opens in a new tab)
api_cors_header- Set CORS headers in the remote APIauto_restartexec_optsbip- Specify network bridge IPbridge- Attach containers to a network bridgechecksum- sha256 checksum of Docker binarycluster_advertise- IP and port that this daemon should advertise to the clustercluster_store_opts- Cluster store optionscluster_store- Cluster store to usedaemon- Enable daemon modedata_root- Root of the Docker runtimedebug- Enable debug modedefault_ip_address_pool- Set the default address pool for networks creates by dockerdefault_ulimit- Set default ulimit settings for containersdisable_legacy_registry- Do not contact legacy registriesdns_search- DNS search domains to usedns- DNS server(s) to useexec_driver- Exec driver to usefixed_cidr_v6- IPv6 subnet for fixed IPsfixed_cidr- IPv4 subnet for fixed IPsgroup- Posix group for the unix socket. Default todockerhost- Daemon socket(s) to connect to -tcp://host:port,unix:///path/to/socket,fd://*orfd://socketfdhttp_proxy- ENV variable set before for Docker daemon startshttps_proxy- ENV variable set before for Docker daemon startsicc- Enable inter-container communicationinsecure_registry- Enable insecure registry communicationinstall_method- Select script, package, tarball, none, or auto. Defaults toauto.instance- Optional property used to override the name provided in the resource.ip_forward- Enable ip forwardingip_masq- Enable IP masqueradingip- Default IP when binding container portsiptables- Enable addition of iptables rulesipv4_forward- Enable net.ipv4.ip_forwardipv6_forward- Enable net.ipv6.ip_forwardipv6- Enable IPv6 networkinglabelsA 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 levellog_opts- Container's logging driver options (driver-specific)logfile- Location of Docker daemon log filemount_flags- Set the systemd mount propagation flag.mtu- Set the containers network MTUno_proxy- ENV variable set before for Docker daemon startspackage_name- Set the package name. Defaults todocker-cepidfile- Path to use for daemon PID fileregistry_mirror- A string or array to set the preferred Docker registry mirror(s)selinux_enabled- Enable selinux supportsource- 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 "http://get.docker.io/builds/ (opens in a new tab)".storage_driver- Storage driver to usestorage_opts- Set storage driver optionstls_ca_cert- Trust certs signed only by this CA. Defaults to ENV['DOCKER_CERT_PATH'] if settls_client_cert- Path to TLS certificate file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if settls_client_key- Path to TLS key file for docker cli. Defaults to ENV['DOCKER_CERT_PATH'] if settls_server_cert- Path to TLS certificate file for docker servicetls_server_key- Path to TLS key file for docker servicetls_verify- Use TLS and verify the remote. Defaults to ENV['DOCKER_TLS_VERIFY'] if settls- Use TLS; implied by --tlsverify. Defaults to ENV['DOCKER_TLS'] if settmpdir- ENV variable set before for Docker daemon startsuserland_proxy- Enables or disables docker-proxyuserns_remap- Enable user namespace remapping options -default,uid,uid:gid,username,username:groupname(see: [Docker User Namespaces](see: https://docs.docker.com/v1.10/engine/reference/commandline/daemon/#daemon-user-namespace-options (opens in a new tab)))live_restore- Keep containers alive during daemon downtime (see: Live restore (opens in a new tab))version- Docker version to install
Miscellaneous Options
misc_opts- Pass the docker daemon any other options bypassing flag validation, supplied as--flag=value
Systemd-specific Options
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.
Actions
: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
docker_service implementations
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.