0

I succeeded in connecting to a remote server configured with Docker through vscode. By the way, the list of containers from the past was fetched from the remote explorer of vscode. If you look at this list of containers, they are obviously containers made with images I downloaded a few days ago. I don't know why this is happening.

Presumably, it is a problem with the settings.json file or a problem with some log.

I pressed f1 in vscode and select Remote-Containers: Attach to Running Container...

Remote Containers screenshot

Then the docker command was entered automatically in the terminal. Here, a container (b25ee2cb9162) that I do not know where it came from has appeared.

Terminal output screenshot

After running this container, a new window opens with the message Starting Dev Container.

This is the list of containers that I said downloaded a few days ago. This is what vscode showed me.

Stopped containers listed in screenshot

What's the reason that this happened?

cam
  • 4,409
  • 2
  • 24
  • 34

1 Answers1

0

Those containers you are seeing are similar to those if you run docker container ls. The containers you are seeing have exited and are not automatically cleaned up by Docker unless specified in CLI --rm option.

The docs for the --rm option explain the reason for this nicely:

By default a container’s file system persists even after the container exits. This makes debugging a lot easier (since you can inspect the final state) and you retain all your data by default. But if you are running short-term foreground processes, these container file systems can really pile up. If instead you’d like Docker to automatically clean up the container and remove the file system when the container exits, you can add the --rm flag:

From this answer about these non-running containers taking up system resources you don't have to be concerned about these taking up much space expect minimal disk space.

To remove those containers, you have a few options:

[Preemptive] Use --rm flag when running container

You can pass the --rm flag when you run a container with the Docker to remove the containers after they have exited so old containers don't accumulate.

As the docs mention, the downside is after the container exits, it's difficult to debug why the container exited if something failed inside the container.

Clean up existing containers from the command line

Use the docker container prune command to remove all stopped containers.

Clean up containers from VSCode

VSCode Docker Containers Extension you clean up containers if you open the command palate and enter Docker Containers: Remove

Or you can simply right click those containers.

screenshot of docker containers remove

screenshot of prompt to remove containers

cam
  • 4,409
  • 2
  • 24
  • 34
  • Thank you for the reply. I think my question was more vague than I thought. I'll edit it to a better question and post it again. Thank you again! – Suhwan Choi Aug 08 '21 at 09:50