docker icon indicating copy to clipboard operation
docker copied to clipboard

docker_container run: no implicit conversion of nil into String

Open kpettijohn opened this issue 12 years ago • 4 comments

My initial first run works as expected but the next time chef-client runs I get the following error.

no implicit conversion of nil into String

Any feedback on how I can resolve this would be much appreciated and I apologize if I'm doing something obviously wrong!

Here is the full output:

    ================================================================================
    Error executing action `run` on resource 'docker_container[registry]'
    ================================================================================

    TypeError
    ---------
    no implicit conversion of nil into String

    Cookbook Trace:
    ---------------
    /root/.chef/local-mode-cache/cache/cookbooks/docker/providers/container.rb:144:in `start_with?'
    /root/.chef/local-mode-cache/cache/cookbooks/docker/providers/container.rb:144:in `container_id_matches?'
    /root/.chef/local-mode-cache/cache/cookbooks/docker/providers/container.rb:126:in `container_matches?'
    /root/.chef/local-mode-cache/cache/cookbooks/docker/providers/container.rb:7:in `block in load_current_resource'
    /root/.chef/local-mode-cache/cache/cookbooks/docker/providers/container.rb:6:in `each'
    /root/.chef/local-mode-cache/cache/cookbooks/docker/providers/container.rb:6:in `load_current_resource'

    Resource Declaration:
    ---------------------
    # In /root/.chef/local-mode-cache/cache/cookbooks/docker-registry/recipes/default.rb

     20: docker_container 'registry' do
     21:   image 'registry'
     22:   detach true
     23:   port node['docker-registry']['port']
     24:   env "SETTINGS_FLAVOR=#{node['docker-registry']['settings_flavor']}"
     25:   env "DOCKER_REGISTRY_CONFIG=#{node['docker-registry']['config_container_path']}/config.yml"
     26:   volume "#{node['docker-registry']['config_host_path']}:#{node['docker-registry']['config_container_path']}"
     27: end

    Compiled Resource:
    ------------------
    # Declared in /root/.chef/local-mode-cache/cache/cookbooks/docker-registry/recipes/default.rb:20:in `from_file'

    docker_container("registry") do
      action :run
      retries 0
      retry_delay 2
      guard_interpreter :default
      cookbook_name "docker-registry"
      recipe_name "default"
      image "registry"
      detach true
      port "5000:5000"
      env "DOCKER_REGISTRY_CONFIG=/registry-conf/config.yml"
      volume "/docker/registry:/registry-conf"
      cmd_timeout 60
    end


Running handlers:
[2014-11-06T17:43:38+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-11-06T17:43:38+00:00] ERROR: Exception handlers complete
[2014-11-06T17:43:38+00:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 25.679801522 seconds
[2014-11-06T17:43:38+00:00] ERROR: docker_container[registry] (docker-registry::default line 20) had an error: TypeError: no implicit conversion of nil into String
[2014-11-06T17:43:39+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Here is the output from docker ps -a --no-trunc:

CONTAINER ID                                                       IMAGE               COMMAND                               CREATED             STATUS              PORTS                    NAMES
9126fafcd0359071cff5ba55bcad01594b006548fc9d4218c0b062e1096a6d58   registry:latest     "/bin/sh -c 'exec docker-registry'"   6 minutes ago       Up 6 minutes        0.0.0.0:5000->5000/tcp   registry
docker --version
Docker version 1.3.1, build 4e9bbfa

kpettijohn avatar Nov 06 '14 17:11 kpettijohn

Hi @kpettijohn, which version of the docker cookbook were you using?

Assuming 0.35.2 (guessing from the stacktrace), the error happens because new_resource.id (which is filled from parsing the docker ps --no-trunc output) is nil. Still have to figure out why it is nil.

Can you still reproduce the issue with version 0.36.0 of the cookbook or (better) github master (lots of fixes waiting for new release)? If you do, I will look up how to reproduce on my side and fix it.

jperville avatar Dec 02 '14 07:12 jperville

Hey @jperville, thanks for getting back to me on this issue. I should have time next week to verify if I still seeing this issue with version 0.36.0/master.

I'm not totally sure what version of the cookbook I was using as I didn't pin it to a version and I have terminated the instances on which I was testing. I will report back next week with my findings.

kpettijohn avatar Dec 04 '14 23:12 kpettijohn

Just verified that this no longer happens to me on 0.36.0 FYI

mincedmit avatar Jan 29 '15 16:01 mincedmit

Sorry for the delay but I can also verify that this is no longer happening to me on 0.36.0

kpettijohn avatar Jan 29 '15 20:01 kpettijohn