puppetlabs / puppetlabs/puppetlabs-docker

docker::run fails if a docker network exists with the same name

Open
#1,015 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
94
Forks
337
Avg merge
11d 15h
Merged PRs (30d)
2

Description

Describe the Bug

If a docker network exists with the same name as the container created by docker::run, the following error results:

Error: Failed to apply catalog: undefined method `[]' for nil:NilClass                                                                                                  
/opt/puppetlabs/puppet/cache/lib/puppet/functions/docker_params_changed.rb:86:in `detect_changes'

Expected Behavior

docker::run should work

Steps to Reproduce

Apply

  docker_network{'prometheus':
    driver => 'bridge',
  }

  docker::run{'prometheus':
    image => 'prom/prometheus',
    ports => '9090:9090',
    restart => 'always',
    net => 'prometheus',
  }

Environment

  • Version 10.2.0
  • Platform Ubuntu 24.04, Puppet 8.10.0

Workaround

  • Rename network or container
  • Remove network manually
  • Re-apply catalog

Additional Context

The issue seems to be that docker_params_changed.rb runs docker inspect and doesn't check whether it's getting results for the right thing.

param_changed = true if opts['image'] && opts['image'] != inspect_hash['Config']['Image']

^ For the network, there is no Image key.

Even if this doesn't need to get fixed, finding this on a search may help someone not waste time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in docker_params_changed.rb around line 86, then reproduce the issue with the docker_network and docker::run Puppet resources shown in the report on the stated environment. Check how docker inspect results are handled when the network and container share a name. Done means docker::run applies successfully without the nil error and the existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, ruby
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.