Broken docker image not listed by ps

Expected behavior

When I run docker ps I expected to see a container listed, but none is there.

Actual behavior

No container is listed when I run docker ps but if I try to create a new docker it says a current docker name is currently in use.

Information

OS X: version 10.11.3 (build: 15D21)
Docker.app: version v1.11.1-beta10
Running diagnostic tests:
[OK] docker-cli
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Docker logs are being collected into /tmp/20160505-134947.tar.gz
Most specific failure is: No error was detected
Your unique id is: 65C418E1-4514-4776-B45A-F95D7AEFC861

Reproduce

Here’s how you can reproduce the problem.

  1. Start a local hosting app such as php -s or fire up Apache or Nginx on port 80 on the local machine. Anything will work.

  2. Try to run the nginx server as described in the getting started page (Docker: Accelerated Container Application Development).

docker run -d -p 80:80 --name webserver nginx

Oops, you get the following error because you have another service running on port 80.

docker: Error response from daemon: driver failed programming external connectivity on endpoint webserver (8e25a81089756408597a1e910cd7990e57c478c283d63d4f76dea7fe374e27fa): Error starting userland proxy: Failed to bind: EADDRINUSE.
  1. Realize your error and run docker ps to see if you created a broken docker. Notice that the list is empty. [I’m a noob, is this a bug?]
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
  1. Okay, it’s clean so now try to create the docker on another port with the following command.

docker run -d -p 8888:80 --name webserver nginx

Oops, you get another error. This time you already have a docker with that name. [Huh? I thought I didn’t have any?]

docker: Error response from daemon: Conflict. The name "/webserver" is already in use by container bebafac5d995b0122fa5c937c8815337639ccc7b5dd19c24ef75d5e49f239e44. You have to remove (or rename) that container to be able to reuse that name..
See 'docker run --help'.
  1. Delete the docker based on the container listed in the error message and try again to work around the issue.

docker rm bebafac5d995b0122fa5c937c8815337639ccc7b5dd19c24ef75d5e49f239e44

docker ps only shows running containers; docker ps -a shows them all, including the stopped one.

Since you specified a --name for the container, you don’t need docker ps to find it; you can docker rm webserver without knowing its hex ID.