Skip to content

A few nsenter errors during exec_create and exec_start #705

@Jeffdude

Description

@Jeffdude

Hello, I'm running some commands in an exec instance and I expect some of them to fail, but I'm having issues with them failing in unexpected ways.

Code:

container = self.client.create_container(image=full_name, tty=True, command=inf_loop, name=container_name)
self.client.start(container=container.get('Id'))
commands = ['apt-get update',
            'apt-get install -y {}'.format(package),
            'yum install -y {}'.format(package)]
for comm in commands:
    this_comm = "/bin/bash -c \'{}\'".format(comm)
    executor = self.client.exec_create(container=container_name, cmd=this_comm)
    response = self.client.exec_start(executor.get('Id'))
    print("----------- Response")
    print(response)

Expected response (from docker cli):

[jeff@virgo]$ docker exec -ti harbortester /bin/bash -c 'apt-get install blah'
/bin/bash: apt-get: command not found

Docker-py responses:

At first I kept seeing this one:

----------- Response
nsenter: Failed to open ns file /proc/12201/ns for ns net: No such file or directory
Cannot run exec command b9b4699030d85d4aa811cf02768da44e203a921323c2bf71060b39c9e751bd7e in container 77b2994cbfb7bdd59d51aefbc82b71165f76ef27e3118d6c6d12397f143c6197: [8] System error: exit status 1
Error starting exec command in container b9b4699030d85d4aa811cf02768da44e203a921323c2bf71060b39c9e751bd7e: Cannot run exec command b9b4699030d85d4aa811cf02768da44e203a921323c2bf71060b39c9e751bd7e in container 77b2994cbfb7bdd59d51aefbc82b71165f76ef27e3118d6c6d12397f143c6197: [8] System error: exit status 1

And now I also see this error:

----------- Response
nsenter: Unable to fork: Cannot allocate memory
Cannot run exec command 11529e2c2f7c9fdc27b514ed72bd233654b55babdf0e302cacbd8d3b1049f345 in container 0db8493a6fd9573abd02e836cb05d16fe805a49f16dc644bd36be90723c235fe: [8] System error: exit status 1
Error starting exec command in container 11529e2c2f7c9fdc27b514ed72bd233654b55babdf0e302cacbd8d3b1049f345: Cannot run exec command 11529e2c2f7c9fdc27b514ed72bd233654b55babdf0e302cacbd8d3b1049f345 in container 0db8493a6fd9573abd02e836cb05d16fe805a49f16dc644bd36be90723c235fe: [8] System error: exit status 1

Both of these errors crash the container.
An important note is that I have also sometimes gotten the intended result

----------- Response
/bin/bash: apt-get: command not found

And I can't seem to figure out what is causing this or how to get more debug information from the errors. Here's some system info. Let me know if you need more information from me.

[jeff@virgo]$ pip show docker-py

---
Metadata-Version: 1.1
Name: docker-py
Version: 1.2.2
Summary: Python client for Docker.
Home-page: https://github.com/docker/docker-py/
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /usr/lib/python2.7/site-packages
Requires: requests, six, websocket-client

[jeff@virgo]$ docker version
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): ba1f6c3/1.6.2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): ba1f6c3/1.6.2
OS/Arch (server): linux/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions