Skip to content

Commit 89ab896

Browse files
authored
Merge pull request #4 from jonathadv/feature-htop-poiting-to-host-proc
Build `htop` from source so that it can see host's processes
2 parents 3bd765b + 817150d commit 89ab896

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

Dockerfile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# Using a build stage in order to build htop using the flag `--with-proc=/proc_host`
2+
# which allows it to use a custom location instead of `/proc`.
3+
FROM alpine:3.6 as builder
4+
5+
WORKDIR /build
6+
RUN apk add --update alpine-sdk build-base ncurses-dev autoconf automake curl unzip
7+
RUN curl -L https://github.com/hishamhm/htop/archive/master.zip --output htop.zip
8+
RUN unzip htop.zip
9+
RUN cd htop-master
10+
11+
WORKDIR /build/htop-master
12+
RUN sh autogen.sh
13+
RUN sh configure --prefix=/build/htop-master/dist --with-proc=/proc_host
14+
RUN make
15+
RUN make install
16+
17+
18+
# Main Container
119
FROM alpine:3.6
220

321
MAINTAINER Jonatha Daguerre <[email protected]>
@@ -6,7 +24,6 @@ RUN apk add --no-cache \
624
bash \
725
bind-tools \
826
curl \
9-
htop \
1027
iptraf-ng \
1128
iotop \
1229
jq \
@@ -19,3 +36,4 @@ RUN apk add --no-cache \
1936
tcpdump \
2037
vim
2138

39+
COPY --from=builder /build/htop-master/dist/bin/htop /usr/local/bin/

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This project focus on providing system administration and troubleshooting tools
1010
* **bash** - GNU Bourne-Again SHell.
1111
* **bind-tools** - The ISC DNS tools (dig, nslookup, host).
1212
* **curl** - Tool to transfer data from or to a server.
13-
* **htop** - A ncurses-based process viewer for Linux.
13+
* **htop** - A ncurses-based process viewer for Linux. (built from source, allows to watch the **host's processes**)
1414
* **iotop** - Simple top-like I/O monitor.
1515
* **iptraf-ng** - An IP Network Monitoring tool.
1616
* **jq** - Commandline JSON processor.
@@ -27,7 +27,9 @@ This project focus on providing system administration and troubleshooting tools
2727

2828
Use `--net=host` allows `tcpdump` to access the host's network interfaces.
2929

30-
Optionally you can create a local directory and map it to the container:
30+
Use `-v /proc:/proc_host` allows `htop` to watch the host's processes. Note that `htop` is unable to kill any host's processes.
31+
32+
Optionally you can create a local directory and map it to the container like `-v /tmp/data/:/tmp/data/`:
3133

3234
```bash
3335
mkdir /tmp/data
@@ -36,6 +38,7 @@ docker run \
3638
--rm \
3739
--name toolkit \
3840
--net=host \
41+
-v /proc:/proc_host \
3942
-v /tmp/data/:/tmp/data/ \
4043
-it \
4144
jonathadv/admin-toolkit \

0 commit comments

Comments
 (0)