Skip to content

docker_container fails to :runΒ #1146

Description

@urlund

πŸ‘» Brief Description

Cannot :run containers.

πŸ₯ž Cookbook version

Version: 7.2.2

πŸ‘©β€πŸ³ Version

Chef: 14.15.6

🎩 Platform details

Fails on a newer docker version (Server Version: 19.03.13 - docker desktop for mac) but it works on an older version (Server Version: 19.03.12 - debian)

I'm running chef in a docker container and mounts the socket as a volume, like this:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock username/chef-client

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a simple recipe with the following content:
# ...
docker_image "nginx:latest" do
    repo   "nginx"
    tag    "latest"
    action :pull
end

# ...
docker_image "php:7.4-fpm" do
    repo   "php"
    tag    "7.4-fpm"
    action :pull
end

#...
docker_container "test_nginx" do
    repo    "nginx"
    port    [ "8080:80", "8443:443" ]
end

# ...
docker_container "test_php_1" do
    repo         "php"
    tag          "7.4-fpm"
end

# ...
docker_container "test_php_2" do
    repo         "php"
    tag          "7.4-fpm"
end
  1. Include in run_list

πŸš“ Expected behavior

I get this on an older docker version (running on debian)

Recipe: test::default
  * docker_image[nginx:latest] action pull
    - Pull image nginx:latest
  * docker_image[php:7.4-fpm] action pull
    - Pull image php:7.4-fpm
  * docker_container[test_nginx] action run
    - create test_nginx
    ...
    - starting test_nginx
  * docker_container[test_php_1] action run
    - create test_php_1
    ...
    - starting test_php_1
  * docker_container[test_php_2] action run
    - create test_php_2
    ...
    - starting test_php_2

On a newer version (docker desktop) I get this:

Recipe: test::default
  * docker_image[nginx:latest] action pull
    - Pull image nginx:latest
  * docker_image[php:7.4-fpm] action pull
    - Pull image php:7.4-fpm
  * docker_container[test_nginx] action run

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

    Excon::Error::Socket
    --------------------
    no implicit conversion of nil into String (TypeError)

    Cookbook Trace:
    ---------------
    /etc/chef/.cache/cookbooks/docker/libraries/docker_container.rb:408:in `block (2 levels) in <class:DockerContainer>'
    /etc/chef/.cache/cookbooks/docker/libraries/docker_base.rb:29:in `with_retries'
    /etc/chef/.cache/cookbooks/docker/libraries/docker_container.rb:408:in `block in <class:DockerContainer>'

    Resource Declaration:
    ---------------------
    # In /etc/chef/.cache/cookbooks/test/recipes/default.rb

     25: docker_container "test_nginx" do
     26:     repo    "nginx"
     27:     port    [ "8080:80", "8443:443" ]
     28: end
     29:

    Compiled Resource:
    ------------------
    # Declared in /etc/chef/.cache/cookbooks/test/recipes/default.rb:25:in `from_file'

βž• Additional context

I've done some digging and it seems to be an issue with the the response format from the docker socket.

I've previously used the docker cookbook on docker desktop for mac, where everything has been working as expected, thats why I suspect the docker version to be the reason for this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In ProgressMaintenanceMaintenance issues such as failing buildsTech DebtWill improve the maintainability of the codebase

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions