2

I try to deploy an app in docker container using mcr.microsoft.com/dotnet/aspnet:5.0 image that need to have top command

when I try to run top command the following result shown:

bash: top: command not found

how can I install top command?

2 Answers 2

6

I try to run following command inside docker container to search top command

$ apt-file search --regexp '/top$'

The result:

broctl: /usr/share/broctl/scripts/helpers/top
crossfire-maps: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
crossfire-maps-small: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
liece: /usr/share/emacs/site-lisp/liece/styles/top
lxpanel: /etc/xdg/lxpanel/two_panels/panels/top
open-infrastructure-container-tools: /usr/lib/open-infrastructure/container/top
procps: /usr/bin/top
quilt: /usr/share/quilt/top

so I try to install procps using following command inside the docker container

$ apt install procps
3
  • And you didn't bother to tell us what the result of that command was or if you ran it INSIDE of the docker container or the docker host. I am kinda guessing that this was run from the host. Commented May 2, 2021 at 3:04
  • 1
    worked by installing procps
    – mon
    Commented Jan 1, 2022 at 3:05
  • This worked for me. If you get an error when you run apt install procps just restart your SSH connection to the Virtual Machine. Commented Jun 27, 2022 at 15:00
0

Its probably intentional - the docker philosophy is pretty much one application/process a container with whatever it needs to run.

You're unlikely to need a full set of userland tools in a container. If you do need to inspect the container itself, you can use docker top from the system running the docker instance instead.

1
  • 1
    I 'sort of' agree with you but we use them for everything. Testing environments.. build environments.. whatever.. and these environments contain whatever tools are needed to get the job done for that container. If you are talking about the containers we provide to customers.. yes, they are stripped, but that isn't the only way to use docker. Commented May 2, 2021 at 3:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .