简体   繁体   中英

How to use puppet to configure the docker daemon on service start up

I am using puppet to configure a docker instance. Below is a code snippet that starts docker on the instance.

  service { 'docker':
    ensure   => running,
    name     => 'docker',
    provider => 'systemd',
    enable   => true,
    require  => [ File['/root/.docker/config.json'], File['/etc/sysconfig/docker'], Package['docker-ce'] ]
  }

According to the docker documentation, you can pass in arguments to set different configurations when starting the docker daemon.

for example dockerd --icc=false will start docker and apply the config change for icc .

I know I can add config changes to a daemon.json file and have docker pick that up, but I want to figure out how to make the config changes live in the puppet code.

So how can I specify config changes like --icc=false when starting docker the way I am in the puppet code above??

So how can I specify config changes like --icc=false when starting docker the way I am in the puppet code above??

You can't. The resource declaration you present ensures that the Docker daemon is running, but it does not directly execute dockerd , and therefore provides no mechanism for passing arguments to the daemon binary. It does specifically manage the daemon via systemd , however, so you could do what you describe by having Puppet manage the corresponding systemd unit file, but that's not meaningfully different than managing daemon.json (via Puppet) instead.

It is absolutely normal, by the way, to manage the configuration (file) of a service and the run state of that service via different Puppet resources. Usually one also manages the package providing the service, too, wrapping all that up into a module. In fact, there are several pre-built Docker modules available already, including one built and maintained by Puppet, Inc., itself .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM