Cannot remove container -> filename too long error

I’ve been unable to remove two containers which I think are leftover from building a dockerfile.

I’m running Docker version 17.09.0-ce, build afdb6d4

with a docker ps -a i see the following containers:

CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                       PORTS               NAMES
6179e9058de1        2c4a85d18e4f         "/bin/sh -c 'pip i..."   3 weeks ago         Removal In Progress                               wizardly_spence
0eb18213423c        5b4e3fa33fe2         "/bin/sh -c 'pip i..."   3 weeks ago         Dead                                              vigorous_easley

Both of which appear to be intermediate containers from building the same dockerfile.

When I try to remove one of them, I get the error written below, which is less-than-helpful. I can’t seem to do anything with Kitematic, docker rm 6179e9058de1, force or what have you.

Any ideas from an officionado?

Error response from daemon: driver "overlay2" failed to remove root filesystem for 6179e9058de1750ac69db7c5a10b6c5b5d676e6e4fc2c2404eba2d9a8ec75b62: lstat /var/lib/docker/overlay2/f8f8c98c9012071df80d314faa2f58d719fdc6caefc6334c2313bfffdba77057/diff/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/tmp/pip-JIiQG1-build/root/.bashrc: file name too long

The dockerfile really isn’t anything special either, just a python environment…

FROM ubuntu:17.10
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
        vim \
		git \
        curl wget \
        mercurial \
        make \
        build-essential \ 
        libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
        llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev

ENV PYENV_ROOT /root/.pyenv
ENV PATH /root/.pyenv/shims:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

Inspect tells me:

        "Created": "2017-10-02T07:43:35.020049011Z",
        "Container": "5e01e8671368a03e3292a1c166a2d1010e19c570397ef8092862ccf1535baf39",
        "ContainerConfig": {
            "Hostname": "88eoef23f1ef",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ADD file:031256979dbec33fc91b77f5893a7c78e970cff186c037feaea84bf0567e9677 in development.ini "
            ],
            "ArgsEscaped": true,
            "Image": "sha256:e2ec8d3847edc1a70e537f7aef0185461328f42d1c68fd0107bcf1427d986a01",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": [],
            "Labels": {}
        },
        "DockerVersion": "17.06.2-ce",

Just curious, did you try docker rm -f <container id> as well?

Also, maybe this is just an artifact of how Docker implements the RUN command (haven’t really looked too closely at that), but is your pyenv installer attempting to add files using the ADD directive?

one thing that I can offer which can really help you with learing Docker Commands is the --help
you can find the sub commands easily for any command. docker rm --help provides you with lots for detail.
$ docker rm --help

Usage: docker rm [OPTIONS] CONTAINER [CONTAINER…]

Remove one or more containers

Options:
-f, --force Force the removal of a running container (uses SIGKILL)
–help Print usage
-l, --link Remove the specified link
-v, --volumes Remove the volumes associated with the container

Hope this helps

Thanks for the replies both.

I have already, of course, tried docker rm --force. I mentioned this in my post but clearly not explicitly enough :slight_smile:

And I re-verified that gist does not run any ADD commands.

I have since created https://github.com/docker/for-mac/issues/2192

For long path error, try LongPathTool, It is helpful.