Unable to start any new containers

root@docker:~# docker run -d ubuntu
Unable to find image ‘ubuntu:latest’ locally
latest: Pulling from library/ubuntu

0bf056161913: Pull complete
1796d1c62d0c: Pull complete
e24428725dd6: Pull complete
89d5d8e8bafb: Pull complete
Digest: sha256:a2b67b6107aa640044c25a03b9e06e2a2d48c95be6ac17fb1a387e75eebafd7c
Status: Downloaded newer image for ubuntu:latest
root@docker:~# docker ps -a | grep ubuntu
3ffb91885051 ubuntu “/bin/bash” 9 seconds ago Exited (0) 9 seconds ago silly_almeida
root@docker:~# docker logs silly_almeida

This is reproducible with other images. However, I am able to start existing containers.

This has brought my work to a grinding halt. I’ve tried restarting the machine that’s hosting docker… but everything still behaves the same.

Hey @runeasgar, everything seems normal here.

Recall how docker run works …

You need a command (and optionally arguments) after the image name, which I didn’t see you supply.

So docker ran your image and exited immediately. That’s why you get the "3ffb91885051 ubuntu “/bin/bash” 9 seconds ago Exited (0) 9 seconds ago " message.

Let me know if you need more help!

1 Like

@runeasgar, I agree with @erictsang, the standard ubuntu image doesn’t run any applications, you need to tell it what to run. You could try this instead:

$ docker run -i -t ubuntu /bin/bash

This will run the bash shell inside the container (and not run in the background). This has little practical purpose other than to help you look inside the container to see how things work.

1 Like

Thanks guys! I managed to figure this out through trial and error, and I definitely understand the need for /bin/bash now (although I went with a start.sh script that does service apache2 start then /bin/bash), but I don’t fully understand the -it. I guess it has something to do with making /bin/bash run in the foreground persistently.

It seems like there should be a better way than /bin/bash to keep a machine running??