Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

puppet wants to create containers after the host is rebooted. with restarts => always. while the container with that name already exists. #674

Open
itsSaad opened this issue Apr 27, 2017 · 2 comments

Comments

@itsSaad
Copy link

itsSaad commented Apr 27, 2017

When i run puppet, it runs all the containers specified in puppet with hiera. the puppet agent run is successful. But when i restart the server, docker runs the containers on boot as i have mentions restart: always in my hiera config.After the boot when puppet agent is run, it throws error because it tries to create those containers again and docker::run fails because the containers with the exact name is already present.
This is my hiera config.

someclass::docker::containers:
  reverse_proxy:
    image: jwilder/nginx-proxy
    ports:
      - '80:80'
    volumes:
      - '/etc/nginx/sites-enabled/:/etc/nginx/custom-conf/'
      - '/etc/nginx/custom-conf/custom.conf:/etc/nginx/conf.d/custom.conf'
      - '/var/run/docker.sock:/tmp/docker.sock:ro'
    detach: true
    restart: always
    use_name: true
  health_check:
    image: nginx
    ports: 81:80
    detach: true
    restart: always
    use_name: true

and from puppet i use it as:

  create_resources(docker::run, $containers)

Error on puppet agent:

Error: /Stage[main]/SomeClass::Docker/Docker::Run[health_check]/Exec[run health_check with docker]/returns: change from notrun to 0 failed: docker run -d --net bridge -m 0b --detach=true -p 81:80  --name health-check --cidfile=/var/run/docker-health-check.cid --restart="always" nginx  returned 125 instead of one of [0]

I also added use_name: true but thats been deprecated. so doesn't seem to a problem regarding that.

Version:
garethr-docker 5.0.0
garethr-docker 5.3.0
on AmazonLinux

@scotty-c
Copy link
Contributor

@itsSaad when Docker returns the error code 125 it is an issue with the demon. Please see here https://docs.docker.com/engine/reference/run/#exit-status. Is the Docker Deamon starting correctly after the reboot?

@sathieu
Copy link

sathieu commented Aug 18, 2017

The reason is probably that the cid file is in /var/run, which is cleaned on reboot. Maybe put this in /var/cache/puppet-garethr-docker or /var/lib/puppet/garethr-docker or similar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants