garethr / garethr-docker

Puppet module for managing docker
Apache License 2.0
397 stars 529 forks source link

puppet-docker module running docker 1.12 should "docker service create" instead of docker run if the node is docker 1.12 swarm #563

Open freibuis opened 8 years ago

freibuis commented 8 years ago

since the release Docker 1.12, docker service create should be used instead of docker run if the node is part of the docker swarm created by or join/init or create an swarm hash inside docker::run

I propose that docker::run should be an alias of the service create command. may be some thing like this

as a swarm hash

docker::run { 'helloworld':
    image       => 'base'
    command => '/bin/sh -c 'echo "hello world"',
    swarm      => {
    ensure          => true,
    replicas         => 10,
    mode            => 'global',
    restart-delay => 2
  },
}

or

docker::run { 'helloworld':
    image          => 'base'
    command    => '/bin/sh -c 'echo "hello world"',
    swarm          => true,
    replicas        => 10,
    mode           => 'global',
    restart-delay => 2
  },
}

should run as

docker service create --replicas=10 --mode=global base /bin/sh -c 'echo "hello world"

info from here https://docs.docker.com/engine/reference/commandline/service_create/

the reason for creating it in docker::run is because docker::service is already taken and I believe that in the future docker will notice that its in the swarm service command is really the same/alias to the docker run command with extras like --replicas

BarnumD commented 7 years ago

I'm trying to figure out if this module can be used to initialize a docker swarm cluster from scratch. And then the next step would be of course what this issue is about - managing services.

Can 5.3.0 initialize a docker swarm? What is the roadmap/timeline for incorporating docker 1.12+ swarm support?