Inspect non-daemon Docker container, after it has completed running

Viewed 587

I have a container that I create with

# start
docker build -t cdt-tests .
docker run -it --name cdt-tests cdt-tests
# end => I want to inspect the container filesystem after it's done

because it's not running in detached mode, how can I inspect the container? What I want to do, is prevent the container from "auto-closing" so that I can inspect the filesystem of the container after it's completed.

The Dockerfile for cdt-tests looks like:

FROM node:6

RUN apt-get update && \
      apt-get -y install sudo

RUN sudo apt-get -y update
RUN sudo apt-get -y upgrade
RUN sudo apt-get install -y sqlite3 libsqlite3-dev

USER root

RUN mkdir -p /tmp/test-deps
RUN mkdir -p /usr/local/cdt-tests
WORKDIR /usr/local/cdt-tests

ENV SUMAN_POSTINSTALL_IS_DAEMON no

RUN rm -rf node_modules

RUN npm set progress=false
RUN npm config set loglevel=warn
RUN npm set loglevel=warn

COPY package.json .

RUN npm install --no-optional > /dev/null 2>&1
RUN npm install bower  > /dev/null 2>&1

COPY . .

RUN ./node_modules/.bin/bower install --config.interactive=false --allow-root  > /dev/null 2>&1

ENTRYPOINT ["/bin/bash", "/usr/local/cdt-tests/@run-tests.sh"]

I know the trick to use, to override the entrypoint, and inspect the container, like so:

docker run -it --entrypoint /bin/bash --name cdt-tests cdt-tests

However, that won't work for my current use case, because I want to inspect the container after @run-tests.sh has completed!

So I have two questions:

  1. How can I inspect the filesystem of a non-daemon container after it has completed running?
  2. How can I get the container id for the container that's created for a non-daemon container (without using $(docker ps)).

If I do a docker ps -a, I see:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                       PORTS               NAMES
08740a432d1c        cdt-tests           "/bin/bash /usr/lo..."   24 seconds ago      Exited (130) 7 seconds ago                       cdt-tests
f27a302b1d8f        cdt-server          "/bin/bash /usr/lo..."   38 seconds ago      Up 36 seconds                                    cdt-server
b854506e75df        cisco-selenium      "/opt/bin/entry_po..."   41 seconds ago      Up 39 seconds                4444/tcp            cdt-selenium
a37cab33b293        mongo               "docker-entrypoint..."   43 seconds ago      Up 41 seconds                27017/tcp           cdt-mongo

so we can see cdt-tests is there, even though it's not a daemon.

So we try to inspect it, something like this:

docker exec cdt-tests /bin/bash

but we get an error:

Error response from daemon: Container 08740a432d1c8f014bc138c82706de1e9682a052c088531d60b33c6acbbd5559 is not running

what to do?

2 Answers
Related