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

Name is already in use by container #534

Closed
joelmoss opened this issue Oct 26, 2015 · 25 comments
Closed

Name is already in use by container #534

joelmoss opened this issue Oct 26, 2015 · 25 comments

Comments

@joelmoss
Copy link

Here is my recipe...

docker_image 'artifactory-oss' do
  repo 'jfrog-docker-registry.bintray.io/jfrog/artifactory-oss'
  action :pull_if_missing
end

docker_container 'artifactory' do
  repo 'jfrog-docker-registry.bintray.io/jfrog/artifactory-oss'
  port '8081:8081'
  binds ['/var/opt/artifactory/data', '/var/opt/artifactory/logs',
         '/var/opt/artifactory/backup', '/var/opt/artifactory/etc']
  subscribes :redeploy, 'docker_image[artifactory-oss]'
end

But every time I run it, I get this error:

Recipe: cr_build::artifactory
  * directory[/var/opt/artifactory] action create (up to date)
  * docker_image[artifactory-oss] action pull_if_missing (up to date)
  * docker_container[artifactory] action run
    - deleting artifactory
    ================================================================================
    Error executing action `run` on resource 'docker_container[artifactory]'
    ================================================================================

    Docker::Error::ConflictError
    ----------------------------
    Conflict. The name "artifactory" is already in use by container 482da335616c. You have to delete (or rename) that container to be able to reuse that name.

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/connection.rb:48:in `rescue in request'
    /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/connection.rb:38:in `request'
    /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/connection.rb:65:in `block (2 levels) in <class:Connection>'
    /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/container.rb:234:in `create'
    /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:181:in `block (3 levels) in <class:DockerContainer>'
    /var/chef/cache/cookbooks/docker/libraries/helpers_base.rb:67:in `call'
    /var/chef/cache/cookbooks/docker/libraries/helpers_base.rb:67:in `with_retries'
    /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:180:in `block (2 levels) in <class:DockerContainer>'
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:38:in `converge_if_changed'
    /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:177:in `block in <class:DockerContainer>'
    /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:159:in `call_action'
    /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:272:in `block in <class:DockerContainer>'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/cr_build/recipes/artifactory.rb

     15: docker_container 'artifactory' do
     16:   repo 'jfrog-docker-registry.bintray.io/jfrog/artifactory-oss'
     17:   port '8081:8081'
     18:   binds ['/var/opt/artifactory/data', '/var/opt/artifactory/logs',
     19:          '/var/opt/artifactory/backup', '/var/opt/artifactory/etc']
     20:   subscribes :redeploy, 'docker_image[artifactory-oss]'
     21: end
     22:

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/cr_build/recipes/artifactory.rb:15:in `from_file'

    docker_container("artifactory") do
      action [:run]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :docker_container
      cookbook_name "cr_build"
      recipe_name "artifactory"
      repo "jfrog-docker-registry.bintray.io/jfrog/artifactory-oss"
      port ["8081:8081"]
      port_bindings {"8081/tcp"=>[{"HostIp"=>"0.0.0.0", "HostPort"=>"8081"}]}
      exposed_ports {"8081/tcp"=>{}}
      binds ["/var/opt/artifactory/data", "/var/opt/artifactory/logs", "/var/opt/artifactory/backup", "/var/opt/artifactory/etc"]
      connection #<Docker::Connection:0x0000000769ca38 @url="unix:///", @options={:socket=>"/var/run/docker.sock", "read_timeout"=>60}>
      network_mode "default"
      api_version "1.20"
    end

Any ideas why?

Even if I manually delete the container, the same error occurs.

@chasebolt
Copy link
Contributor

What is the output when you run docker ps -a? It sounds like there is a
container with that name that was created outside of chef.

On Sunday, October 25, 2015, Joel Moss notifications@github.com wrote:

Here is my recipe...

docker_image 'artifactory-oss' do
repo 'jfrog-docker-registry.bintray.io/jfrog/artifactory-oss'
action :pull_if_missingend

docker_container 'artifactory' do
repo 'jfrog-docker-registry.bintray.io/jfrog/artifactory-oss'
port '8081:8081'
binds ['/var/opt/artifactory/data', '/var/opt/artifactory/logs',
'/var/opt/artifactory/backup', '/var/opt/artifactory/etc']
subscribes :redeploy, 'docker_image[artifactory-oss]'end

But every time I run it, I get this error:

Recipe: cr_build::artifactory

  • directory[/var/opt/artifactory] action create (up to date)

  • docker_image[artifactory-oss] action pull_if_missing (up to date)

  • docker_container[artifactory] action run

    - deleting artifactory

    Error executing action run on resource 'docker_container[artifactory]'

    Docker::Error::ConflictError

    Conflict. The name "artifactory" is already in use by container 482da335616c. You have to delete (or rename) that container to be able to reuse that name.

    Cookbook Trace:

    /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/connection.rb:48:in rescue in request' /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/connection.rb:38:inrequest'
    /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/connection.rb:65:in block (2 levels) in <class:Connection>' /var/chef/cache/cookbooks/docker/files/default/vendor/gems/docker-api-1.22.4/lib/docker/container.rb:234:increate'
    /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:181:in block (3 levels) in <class:DockerContainer>' /var/chef/cache/cookbooks/docker/libraries/helpers_base.rb:67:incall'
    /var/chef/cache/cookbooks/docker/libraries/helpers_base.rb:67:in with_retries' /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:180:inblock (2 levels) in class:DockerContainer'
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:38:in converge_if_changed' /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:177:inblock in class:DockerContainer'
    /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:159:in call_action' /var/chef/cache/cookbooks/docker/libraries/docker_container.rb:272:inblock in class:DockerContainer'

    Resource Declaration:

    In /var/chef/cache/cookbooks/cr_build/recipes/artifactory.rb

    15: docker_container 'artifactory' do
    16: repo 'jfrog-docker-registry.bintray.io/jfrog/artifactory-oss'
    17: port '8081:8081'
    18: binds ['/var/opt/artifactory/data', '/var/opt/artifactory/logs',
    19: '/var/opt/artifactory/backup', '/var/opt/artifactory/etc']
    20: subscribes :redeploy, 'docker_image[artifactory-oss]'
    21: end
    22:

    Compiled Resource:

    Declared in /var/chef/cache/cookbooks/cr_build/recipes/artifactory.rb:15:in `from_file'

    docker_container("artifactory") do
    action [:run]
    retries 0
    retry_delay 2
    default_guard_interpreter :default
    declared_type :docker_container
    cookbook_name "cr_build"
    recipe_name "artifactory"
    repo "jfrog-docker-registry.bintray.io/jfrog/artifactory-oss"
    port ["8081:8081"]
    port_bindings {"8081/tcp"=>[{"HostIp"=>"0.0.0.0", "HostPort"=>"8081"}]}
    exposed_ports {"8081/tcp"=>{}}
    binds ["/var/opt/artifactory/data", "/var/opt/artifactory/logs", "/var/opt/artifactory/backup", "/var/opt/artifactory/etc"]
    connection #<Docker::Connection:0x0000000769ca38 @url="unix:///", @options={:socket=>"/var/run/docker.sock", "read_timeout"=>60}>
    network_mode "default"
    api_version "1.20"
    end

Any ideas why?

Even if I manually delete the container, the same error occurs.


Reply to this email directly or view it on GitHub
#534.

@joelmoss
Copy link
Author

Yes there is a container with the same name, but it's the one created by the recipe. I delete the container and the same thing happens.

@someara
Copy link
Contributor

someara commented Oct 27, 2015

Can you try deleting /usr/bin/docker and upgrading to 2.2.0?

The cookbook will now install the dynamically linked packages from Docker... I'd like to rule out any wonky devicemapper issues here.

-s

@someara
Copy link
Contributor

someara commented Oct 28, 2015

Actually, now that I take a closer look at this, I bet it's failing to properly kill this during the redeploy.

@manuelmazzuola
Copy link

Same issue here
Docker 1.8.3 and chef-docker 2.2.2

* docker_container[sample-app] action redeploy
ERROR: docker_container[sample-app] (cd-docker::default line 95) had an error: Docker::Error::
ConflictError: Conflict. The name "sample-app" is already in use by container 3653d9199912. You have to delete (or rename) that container to be able to reuse that name.
ubuntu@test-cd-docker:~$ sudo docker info
Containers: 1
Images: 10
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 12
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.19.0-31-generic
Operating System: Ubuntu 14.04.2 LTS
CPUs: 1
Total Memory: 3.614 GiB

@someara
Copy link
Contributor

someara commented Nov 9, 2015

I suspect this might be due to the changes in v2.1.12.

The :redeploy action just calls :delete then :create.
(:delete calls :stop.)

https://github.com/someara/chef-docker/blob/fb6e556124a046ff47f48f8bb36d8d5010930825/libraries/docker_container.rb#L308-L309

Prior to 2.1.12, stop wasn't sending the signal correctly, then killed the container without a proper shutdown.

Post 2.1.12, it sends the correct signal. However, it turns out that most programs running-as-pid-1 do not correctly handle SIGTERM for lack of parental zombie reaping.

We had to change the commands used in the redeployer tests to account for this.

https://github.com/someara/chef-docker/blob/fb6e556124a046ff47f48f8bb36d8d5010930825/test/cookbooks/docker_test/recipes/container.rb#L204

^ Based on all that, I suspect the artifactory-oss isn't responding to the SIGTERM properly.

However, if this IS the cause, I would expect chef-client to error before it ever gets to the :create part. Rather than kill the container a timeout (default docker CLI behavior), docker_container should be giving up and erroring after an unsuccessful SIGTERM (in the name of safety).

Can you verify that the container doesn't respond to SIGTERM properly?

@manuelmazzuola
Copy link

The container respond properly to the SIGTERM signal.
The image I've used is cloudesire/sample-app:0.0.1 on docker hub.

@chasebolt
Copy link
Contributor

@manuelmazzuola can you verify this is still an issue with the v2.3.5? if it is, double check if the error message is still the same.

@manuelmazzuola
Copy link

This is still an issue with the v2.3.5
Brand new terraformed machine, at the first run of chef I get

[staging-test] out:                                                                                                                                                                                      [426/1896]
[staging-test] out:     ================================================================================
[staging-test] out:     Error executing action `run` on resource 'docker_container[activemq]'
[staging-test] out:     ================================================================================
[staging-test] out:     
[staging-test] out:     Docker::Error::ConflictError
[staging-test] out:     ----------------------------
[staging-test] out:     Conflict. The name "activemq" is already in use by container bf9a231f1ba1. You have to delete (or rename) that container to be able to reuse that name.
[staging-test] out:     
[staging-test] out:     Cookbook Trace:
[staging-test] out:     ---------------
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/connection.rb:48:in `rescue in request'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/connection.rb:38:in `request'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/connection.rb:65:in `block (2 levels) in <class:Connection>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/container.rb:246:in `create'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:181:in `block (3 levels) in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/helpers_base.rb:57:in `call'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/helpers_base.rb:57:in `with_retries'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:180:in `block (2 levels) in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:67:in `converge_if_changed'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:177:in `block in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `instance_eval'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `compile_and_converge_action'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:159:in `call_action'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:272:in `block in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `instance_eval'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `compile_and_converge_action'
[staging-test] out:     
[staging-test] out:     Resource Declaration:
[staging-test] out:     ---------------------
[staging-test] out:     # In /home/ubuntu/chef/manuel_chef/cookbooks/cd-infrastructure/definitions/cd_container.rb
[staging-test] out:     
[staging-test] out:      27:   docker_container params[:name] do
[staging-test] out:      28:     detach true
[staging-test] out:      29:     container_name params[:name]
[staging-test] out:      30:     repo params[:image_name]
[staging-test] out:      31:     tag params[:image_version]
[staging-test] out:      32:     port params[:port]
[staging-test] out:      33:     env params[:env]
[staging-test] out:      34:     volumes params[:volume]
[staging-test] out:      35:     command params[:command] if params[:command]
[staging-test] out:      36:     params[:subscribes].each do |resource_string|
[staging-test] out:      37:       subscribes :restart, resource_string
[staging-test] out:      38:     end
[staging-test] out:      39:     privileged params[:privileged]
[staging-test] out:      40:     network_mode node['cloudesire']['docker_net']
[staging-test] out:      41:     timeout node['cloudesire']['docker_timeout']
[staging-test] out:      42:     restart_policy 'always'
[staging-test] out:      43:     restart_maximum_retry_count node['cloudesire']['docker_retries']
[staging-test] out:      44:     action params[:action] ? params[:action] : node['cloudesire']['docker_action']
[staging-test] out:      45:   end
[staging-test] out:      46: end
[staging-test] out:     
[staging-test] out:     Compiled Resource:
[staging-test] out:     ------------------
[staging-test] out:     # Declared in /home/ubuntu/chef/manuel_chef/cookbooks/cd-infrastructure/definitions/cd_container.rb:27:in `block in from_file'
[staging-test] out:     
[staging-test] out:     docker_container("activemq") do
[staging-test] out:       params {:name=>"activemq", :image_name=>"cloudesire/activemq", :image_version=>"latest", :image_latest=>true, :port=>"61616:61616", :env=>[], :volume=>["/srv/activemq/data:/opt/activemq
/data/kahadb", "/srv/activemq/conf/activemq.xml:/opt/activemq/conf/activemq.xml", "/srv/activemq/conf/credentials.properties:/opt/activemq/conf/credentials.properties"], :subscribes=>[], :action=>nil, :command=>
nil, :privileged=>false}
[staging-test] out:       action [:run]
[staging-test] out:       retries 0
[staging-test] out:       retry_delay 2
[staging-test] out:       default_guard_interpreter :default
[staging-test] out:       declared_type :docker_container
[staging-test] out:       cookbook_name :"cd-infrastructure"
[staging-test] out:       recipe_name "docker-activemq"
[staging-test] out:       detach true
[staging-test] out:       container_name "activemq"
[staging-test] out:       repo "cloudesire/activemq"
[staging-test] out:       tag "latest"
[staging-test] out:       exposed_ports {"61616/tcp"=>{}}
[staging-test] out:       port_bindings {"61616/tcp"=>[{"HostIp"=>"0.0.0.0", "HostPort"=>"61616"}]}
[staging-test] out:       port "61616:61616"
[staging-test] out:       volumes {"/srv/activemq/data:/opt/activemq/data/kahadb"=>{}, "/srv/activemq/conf/activemq.xml:/opt/activemq/conf/activemq.xml"=>{}, "/srv/activemq/conf/credentials.properties:/opt/activ
emq/conf/credentials.properties"=>{}}
[staging-test] out:       network_mode "host"
[staging-test] out:       timeout 15
[staging-test] out:       restart_policy "always"
[staging-test] out:       restart_maximum_retry_count 2
[staging-test] out:       connection #<Docker::Connection:0x000000059c2b10 @url="unix:///", @options={:socket=>"/var/run/docker.sock", "read_timeout"=>60}>
[staging-test] out:       log_driver "json-file"
[staging-test] out:       security_opts [""]
[staging-test] out:       signal "SIGKILL"
[staging-test] out:       attach_stderr true
[staging-test] out:       attach_stdout true
[staging-test] out:     end

Docker version 1.8.3, build f4bf5c7
Linux staging-test.cloudesire.com 3.19.0-39-generic #44~14.04.1-Ubuntu SMP Wed Dec 2 10:00:35 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Cookbook docker version 2.3.5

Dunno if can help but I've started that container on my computer sudo docker run cloudesire/activemq:latest and then with docker stop mad_curie stopped it, and it works.

@chasebolt
Copy link
Contributor

Before chef runs what docker ps output?

@manuelmazzuola
Copy link

There is no docker before chef runs.
I've retried today with a new terraformed machine on gce.

ubuntu@staging-test:~$ docker ps
The program 'docker' is currently not installed. You can install it by typing:
sudo apt-get install docker

This is the recipe.
The resource cd_container pull the image if necessary and run the run action.

cd_container 'activemq' do
  image_name 'cloudesire/activemq'
  image_version 'latest'
  port '61616:61616'
  volume [
    '/srv/activemq/data:/opt/activemq/data/kahadb',
    '/srv/activemq/conf/activemq.xml:/opt/activemq/conf/activemq.xml',
    '/srv/activemq/conf/credentials.properties:/opt/activemq/conf/credentials.properties'
  ]
end

Then on the first run of chef.

[staging-test] out: Recipe: cd-infrastructure::docker-activemq

[staging-test] out:   * directory[/srv/activemq/conf] action create
[staging-test] out:     - create new directory /srv/activemq/conf
[staging-test] out:   * file[/srv/activemq/conf/credentials.properties] action create
[staging-test] out:     - create new file /srv/activemq/conf/credentials.properties
[staging-test] out:     - update content in file /srv/activemq/conf/credentials.properties from none to 45d8fb

[staging-test] out:   * docker_image[cloudesire/activemq] action pull
[staging-test] out:     - Pull image cloudesire/activemq:latest
[staging-test] out:   * directory[/var/tmp/docker_dump/activemq] action create
[staging-test] out:     - create new directory /var/tmp/docker_dump/activemq
[staging-test] out:     - change mode from '' to '0750'
[staging-test] out:     - change owner from '' to 'root'
[staging-test] out:     - change group from '' to 'root'
[staging-test] out:   * file[/var/tmp/docker_dump/activemq/env.json] action create
[staging-test] out:     - create new file /var/tmp/docker_dump/activemq/env.json
[staging-test] out:     - update content in file /var/tmp/docker_dump/activemq/env.json from none to 4f53cd
[staging-test] out:     --- /var/tmp/docker_dump/activemq/env.json      2015-12-11 08:56:35.995482509 +0000
[staging-test] out:     +++ /var/tmp/docker_dump/activemq/.env.json20151211-2143-1mxhybb        2015-12-11 08:56:35.995482509 +0000
[staging-test] out:     @@ -1 +1,2 @@
[staging-test] out:     +[]

[staging-test] out:   * docker_container[activemq] action run
[staging-test] out:     
[staging-test] out:     ================================================================================
[staging-test] out:     Error executing action `run` on resource 'docker_container[activemq]'
[staging-test] out:     ================================================================================
[staging-test] out:     
[staging-test] out:     Docker::Error::ConflictError
[staging-test] out:     ----------------------------
[staging-test] out:     Conflict. The name "activemq" is already in use by container dba71229c20a. You have to delete (or rename) that container to be able to reuse that name.

Here the relative docker logs:

time="2015-12-11T08:56:13.772553230Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-11T08:56:13.772736032Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-11T08:56:13.772798653Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-11T08:56:13.773549761Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-11T08:56:13.773704051Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-11T08:56:13.773749228Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-11T08:56:13.774520538Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-11T08:56:13.774692411Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-11T08:56:13.774753141Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-11T08:56:13.775687756Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-11T08:56:13.775860692Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-11T08:56:13.775905985Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-11T08:56:13.777074712Z" level=info msg="POST /v1.16/images/create?fromImage=cloudesire%2Factivemq%3Alatest"
time="2015-12-11T08:56:35.988020798Z" level=info msg="GET /v1.16/images/da07db9819f1/json"
time="2015-12-11T08:56:35.990932584Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-11T08:56:35.993684432Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-11T08:56:36.001814864Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-11T08:56:36.002075468Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-11T08:56:36.002132493Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-11T08:56:36.003141074Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-11T08:56:36.003280467Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-11T08:56:36.003325986Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-11T08:56:36.004310713Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-11T08:56:36.004465405Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-11T08:56:36.004514572Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-11T08:56:36.005528630Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-11T08:56:36.005667907Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-11T08:56:36.005712075Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-11T08:56:36.013026506Z" level=info msg="POST /v1.16/containers/create?name=activemq"
time="2015-12-11T08:56:36.040589610Z" level=error msg="Handler for POST /containers/create returned error: cannot mount volume over existing file, file exists /var/lib/docker/overlay/dba71229c20a5c86e64b53c877df39fc71c259af86b331870dba80abd7c67ddb/merged/opt/apache-activemq-5.13.0/conf/activemq.xml"
time="2015-12-11T08:56:36.040639698Z" level=error msg="HTTP Error" err="cannot mount volume over existing file, file exists /var/lib/docker/overlay/dba71229c20a5c86e64b53c877df39fc71c259af86b331870dba80abd7c67ddb/merged/opt/apache-activemq-5.13.0/conf/activemq.xml" statusCode=500
time="2015-12-11T08:56:36.043772796Z" level=info msg="POST /v1.16/containers/create?name=activemq"
time="2015-12-11T08:56:36.045858384Z" level=error msg="Handler for POST /containers/create returned error: Conflict. The name \"activemq\" is already in use by container dba71229c20a. You have to delete (or rename) that container to be able to reuse that name."
time="2015-12-11T08:56:36.045908926Z" level=error msg="HTTP Error" err="Conflict. The name \"activemq\" is already in use by container dba71229c20a. You have to delete (or rename) that container to be able to reuse that name." statusCode=409

@chasebolt
Copy link
Contributor

Ahh I think this is related to #540. Can you confirm you are using the overlay driver?

@manuelmazzuola
Copy link

Yes, overlay driver.
How it is related to that #540 ?

@chasebolt
Copy link
Contributor

It has a slightly different error, but in both cases a container is created and errors out. You both are using the overlay driver, which we don't test against.

I'll setup some test-kitchen runs with it and see if I can reproduce it.

@chasebolt
Copy link
Contributor

Can you update to the latest docker and try that?

@manuelmazzuola
Copy link

Then I'll try right now with aufs. Thank you.

@chasebolt
Copy link
Contributor

Let me know if aufs works fine

@chasebolt
Copy link
Contributor

overlay with docker 1.9.0 on ubuntu 15.04: success
overlay with docker 1.8.3 on ubuntu 15.04: success

not sure what makes your setup different. there are these notes in the docker docs about overlay.

Note: As promising as overlay is, the feature is still quite young and should not be used in production. Most notably, using overlay can cause excessive inode consumption (especially as the number of images grows), as well as being incompatible with the use of RPMs.

Note: It is currently unsupported on btrfs or any Copy on Write filesystem and should only be used over ext4 partitions.

@manuelmazzuola
Copy link

Sorry for the late reply.
Tested with aufs.
Kernel version Linux staging-test.cloudesire.com 3.19.0-39-generic #44~14.04.1-Ubuntu SMP Wed Dec 2 10:00:35 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Same problem here.

ubuntu@staging-test:~$ sudo docker info
Containers: 5
Images: 54
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 64
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.19.0-39-generic
Operating System: Ubuntu 14.04.2 LTS
CPUs: 4
Total Memory: 14.69 GiB
Name: staging-test.cloudesire.com
ID: VSPE:ANMD:PRJ7:7F5V:LOW3:2J4O:WCIX:FVBH:W7GQ:5XEG:IFXD:PBUD
WARNING: No swap limit support
ubuntu@staging-test:~$ 
[staging-test] out:   * docker_container[activemq] action run
[staging-test] out:     
[staging-test] out:     ================================================================================
[staging-test] out:     Error executing action `run` on resource 'docker_container[activemq]'
[staging-test] out:     ================================================================================
[staging-test] out:     
[staging-test] out:     Docker::Error::ConflictError
[staging-test] out:     ----------------------------
[staging-test] out:     Conflict. The name "activemq" is already in use by container 6388ae66cdff. You have to delete (or rename) that container to be able to reuse that name.
[staging-test] out:     
[staging-test] out:     Cookbook Trace:
[staging-test] out:     ---------------
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/connection.rb:48:in `rescue in request'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/connection.rb:38:in `request'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/connection.rb:65:in `block (2 levels) in <class:Connection>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/files/default/vendor/gems/docker-api-1.24.1/lib/docker/container.rb:246:in `create'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:181:in `block (3 levels) in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/helpers_base.rb:57:in `call'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/helpers_base.rb:57:in `with_retries'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:180:in `block (2 levels) in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:67:in `converge_if_changed'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:177:in `block in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `instance_eval'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `compile_and_converge_action'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:159:in `call_action'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/docker/libraries/docker_container.rb:272:in `block in <class:DockerContainer>'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `instance_eval'
[staging-test] out:     /home/ubuntu/chef/manuel_chef/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:118:in `compile_and_converge_action'

Docker logs

time="2015-12-14T10:40:51.615835791Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-14T10:40:51.616017836Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-14T10:40:51.616043467Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-14T10:40:51.617047609Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-14T10:40:51.617200030Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-14T10:40:51.617226090Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-14T10:40:51.618238162Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-14T10:40:51.618417685Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-14T10:40:51.618439926Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-14T10:40:51.619413329Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-14T10:40:51.619571452Z" level=error msg="Handler for GET /images/{name:.*}/json returned error: No such image: cloudesire/activemq:latest"
time="2015-12-14T10:40:51.619606472Z" level=error msg="HTTP Error" err="No such image: cloudesire/activemq:latest" statusCode=404
time="2015-12-14T10:40:51.620912475Z" level=info msg="POST /v1.16/images/create?fromImage=cloudesire%2Factivemq%3Alatest"
time="2015-12-14T10:41:06.855460229Z" level=info msg="GET /v1.16/images/11967aad382b/json"
time="2015-12-14T10:41:06.858736709Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-14T10:41:06.861444746Z" level=info msg="GET /v1.16/images/cloudesire/activemq:latest/json"
time="2015-12-14T10:41:06.871118354Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-14T10:41:06.871396222Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-14T10:41:06.871444693Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-14T10:41:06.872401148Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-14T10:41:06.872526763Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-14T10:41:06.872596056Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-14T10:41:06.873614050Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-14T10:41:06.873735443Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-14T10:41:06.873775899Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-14T10:41:06.874737514Z" level=info msg="GET /v1.16/containers/activemq/json"
time="2015-12-14T10:41:06.874863968Z" level=error msg="Handler for GET /containers/{name:.*}/json returned error: no such id: activemq"
time="2015-12-14T10:41:06.874921152Z" level=error msg="HTTP Error" err="no such id: activemq" statusCode=404
time="2015-12-14T10:41:06.881657764Z" level=info msg="POST /v1.16/containers/create?name=activemq"
time="2015-12-14T10:41:06.897685209Z" level=error msg="Couldn't run auplink before unmount: exec: \"auplink\": executable file not found in $PATH"
time="2015-12-14T10:41:06.917587690Z" level=error msg="Couldn't run auplink before unmount: exec: \"auplink\": executable file not found in $PATH"
time="2015-12-14T10:41:06.927193568Z" level=error msg="Handler for POST /containers/create returned error: cannot mount volume over existing file, file exists /var/lib/docker/aufs/mnt/6388ae66cdff90b0572830a1959f3b78bf048e176791788ab38bc206b40c5927/opt/apache-activemq-5.13.0/conf/activemq.xml"
time="2015-12-14T10:41:06.927258726Z" level=error msg="HTTP Error" err="cannot mount volume over existing file, file exists /var/lib/docker/aufs/mnt/6388ae66cdff90b0572830a1959f3b78bf048e176791788ab38bc206b40c5927/opt/apache-activemq-5.13.0/conf/activemq.xml" statusCode=500
time="2015-12-14T10:41:06.930810990Z" level=info msg="POST /v1.16/containers/create?name=activemq"
time="2015-12-14T10:41:06.933040574Z" level=error msg="Handler for POST /containers/create returned error: Conflict. The name \"activemq\" is already in use by container 6388ae66cdff. You have to delete (or rename) that container to be able to reuse that name."
time="2015-12-14T10:41:06.933107684Z" level=error msg="HTTP Error" err="Conflict. The name \"activemq\" is already in use by container 6388ae66cdff. You have to delete (or rename) that container to be able to reuse that name." statusCode=409

In the docker logs it says that it can't mount volume over existing file but before this logs there is nothing about activemq so this is the first time it tries to run the container.

I forgot to say that the activemq container is runnning even if docker raised the error.
24b1e88f9412 cloudesire/activemq:latest "/activemq.sh" 14 minutes ago Up 14 minutes

This is a new machine terraformed just for this test.
I've this problem only with that specific image, all others containers start fine without errors.

May the force be with me.
I'll investigate further the image https://github.com/ClouDesire/docker-activemq

@manuelmazzuola
Copy link

I cannot mount a file over an existing one in the container?

time="2015-12-14T10:41:06.927258726Z" level=error msg="HTTP Error" err="cannot mount volume over existing file, file exists /var/lib/docker/aufs/mnt/6388ae66cdff90b0572830a1959f3b78bf048e176791788ab38bc206b40c5927/opt/apache-activemq-5.13.0/conf/activemq.xml"

Is the same problem ?
moby/moby#12759

@manuelmazzuola
Copy link

@chasebolt I've found the problem:

This not work:

root@staging-test:/home/ubuntu/curl-7.46.0/src# ./curl --unix-socket /var/run/docker.sock http://v1.18/containers/create -H 'Content-Type: application/json' -d '{"Volumes": {"/opt/activemq/conf/activemq.xml": {}}, "Cmd": ["cat", "/opt/activemq/conf/activemq.xml"], "HostConfig": null, "Image": "cloudesire/activemq"}'

cannot mount volume over existing file, file exists /var/lib/docker/aufs/mnt/e77af92e8375e69bea05c6a6136ee1245a8994cfd92f826875c378846e7672ff/opt/apache-activemq-5.13.0/conf/activemq.xml

This works:

root@staging-test:/home/ubuntu/curl-7.46.0/src# ./curl --unix-socket /var/run/docker.sock http://v1.18/containers/create -H 'Content-Type: application/json' -d '{"Volumes": {"/opt/activemq/conf/activemq.xml": {}}, "Cmd": ["cat", "/opt/activemq/conf/activemq.xml"], "HostConfig": {"Binds": ["/tmp/test:/opt/activemq/conf/activemq.xml"]}, "Image": "cloudesire/activemq"}'

{"Id":"172803a82968cb466d231c0d1bac496776851b000a9d7f049714528f6ea0c245","Warnings":null}

If the Bind entry is missing docker get mad.
For each volume a Bind entry should (must?) be populated.

So, I've modified my cd_container resource from

define :cd_container, :a_lot_of_params do
  docker_container params[:name] do
      volumes params[:volume]
      ecc.
    end
end

to

define :cd_container, :a_lot_of_params do
  docker_container params[:name] do
      volumes params[:volume]
      binds params[:volume]
      ecc.
    end
end

and it works.

[staging-test] out:   * docker_container[activemq] action run
[staging-test] out:     - create activemq
[staging-test] out:     -   set container_name              to "activemq"
[staging-test] out:     -   set repo                        to "cloudesire/activemq"
[staging-test] out:     -   set tag                         to "latest"
[staging-test] out:     -   set command                     to nil (default value)
[staging-test] out:     -   set binds                       to ["/srv/activemq/data:/opt/activemq/data/kahadb", "/srv/activemq/conf/activemq.xml:/op
t/activemq/conf/activemq.xml", "/srv/activemq/conf/credentials.properties:/opt/activemq/conf/credentials.properties"]
[staging-test] out:     - starting activemq

@chasebolt
Copy link
Contributor

@manuelmazzuola i think this is fixed in v2.4.2 now. please give it a spin!

@gionn
Copy link
Contributor

gionn commented Jan 19, 2016

Looks like it's working with volumes, however containers get redeployed on every run:

[staging-nxt] out:   * docker_container[consul] action run
[staging-nxt] out:     - stopping consul  (will kill after 30s)
[staging-nxt] out:     - deleting consul
[staging-nxt] out:     - update consul
[staging-nxt] out:     -   set volumes to nil (was {"/data"=>{}})
[staging-nxt] out:     - starting consul

container resource configured with:

  volumes [
    '/srv/consul-data:/data',
    '/etc/consul.d:/etc/consul.d',
  ]

docker inspect returns:

        "Volumes": {
            "/data": {}
        },

and

    "Mounts": [
        {
            "Source": "/srv/consul-data",
            "Destination": "/data",
            "Mode": "",
            "RW": true
        },
        {
            "Source": "/etc/consul.d",
            "Destination": "/etc/consul.d",
            "Mode": "",
            "RW": true
        }
    ],

Another issue @chasebolt ?

@chasebolt
Copy link
Contributor

what does your complete docker_container resource look like?

@gionn
Copy link
Contributor

gionn commented Jan 20, 2016

whatever was, got fixed bumping from v2.4.2 to v2.4.4 (probably was #608)

Thanks!

@someara someara closed this as completed Jan 21, 2016
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

5 participants