0

I'm kind of new to Docker and Linux. I was wondering what does "running in background" means when it comes to containers since I can't find a process that relates to a background RUNNING container.

I ran htop filtered on docker and started 2 containers:

  1. docker run nginx --> As I expected, a process appeared in htop (child of the shell who launched it)
  2. docker run -d nginx --> Nothing appeared here (the container IS running though)

I couldn't find any explanation (I'm probably just not looking where I should...). What is happening here ?

EDIT:

I eventually figured out the "issue" which, as usual, lay between my chair and my keyboard: I'm running a headless linux VM on macOS and it didn't occur to me (until now (╬ಠ益ಠ)) that I wasn't launching my commands on the VM but directly on my host OS.

So under the hood docker on macOS was using its own linux VM and my htop command only listed the one linked to an opened 'host' terminal...

See How to retrieve docker container name from pid of docker exec on the host (MacOS)

6
  • since I can't find a process that relates to a background RUNNING container. where and how do you search? Commented Jun 28, 2021 at 8:46
  • Hi @KamilCuk, as I stated I'm using htop and its Filter function. I filtered using the keywords "docker" and "nginx" (not simultaneously obviously) Commented Jun 28, 2021 at 9:01
  • as what user? use stackoverflow.com/questions/34878808/… Commented Jun 28, 2021 at 9:07
  • 1
    Thanks for the link, it did help me in the end :). I edited my post. I blame myself for not specifying right at the start that I was working on linux but under MacOS, i think someone would've spotted my mistake right away... I raised a duplicate flag Commented Jun 28, 2021 at 9:45
  • "lied"? I think the word you wanted was "lay". Commented Nov 27, 2022 at 23:31

1 Answer 1

1

Docker containers are, in the end, just processes. It's possible for a container to die though.

If you do docker run -d nginx it'll print out a long hexadecimal string. That's the ID of the new container. You can run docker logs <container-id> to get the logs, e.g. docker logs 123456. You don't need the whole ID, just the first few characters will work.

You can see running containers using docker ps, and see all containers (alive and dead) using docker ps -a.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your time, but I can't see how that answers my question ^^'. My point is: docker run nginx seems to appear in htop as a process while docker run -d nginx does not. I'm not killing the containers, they both appear when I docker container ls (without the -a, which proves they are indeed running)
nginx is probably dying. I can't tell you why, but docker logs might be able to!
Both containers are running (docker container ls - without -a - lists both, I can interact with them, access logs, etc). I added the logs to my post in case it helps

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.