├── .dockerignore ├── .gitignore ├── Dockerfile.bionic ├── Dockerfile.trusty ├── Dockerfile.xenial ├── Makefile ├── README.md └── entrypoint.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !entrypoint.sh 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zlim/bcc-docker/a6f1e093137b3db366c3dd714635be77a1feae7f/.gitignore -------------------------------------------------------------------------------- /Dockerfile.bionic: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | LABEL maintainer="Zi Shen Lim " 3 | 4 | RUN set -ex; \ 5 | echo "deb [trusted=yes] http://repo.iovisor.org/apt/bionic bionic-nightly main" > /etc/apt/sources.list.d/iovisor.list; \ 6 | apt-get update -y; \ 7 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ 8 | auditd \ 9 | bcc-tools \ 10 | libelf1 \ 11 | libbcc-examples; 12 | 13 | COPY entrypoint.sh / 14 | RUN chmod +x /entrypoint.sh 15 | 16 | ENTRYPOINT ["/entrypoint.sh"] 17 | CMD ["/bin/bash"] 18 | -------------------------------------------------------------------------------- /Dockerfile.trusty: -------------------------------------------------------------------------------- 1 | FROM ubuntu:trusty 2 | LABEL maintainer="Zi Shen Lim " 3 | 4 | RUN set -ex; \ 5 | echo "deb [trusted=yes] http://repo.iovisor.org/apt/trusty trusty-nightly main" > /etc/apt/sources.list.d/iovisor.list; \ 6 | apt-get update -y; \ 7 | DEBIAN_FRONTEND=noninteractive \ 8 | apt-get install -y \ 9 | bcc-tools \ 10 | libbcc-examples \ 11 | libelf1; 12 | 13 | COPY entrypoint.sh / 14 | RUN chmod +x /entrypoint.sh 15 | 16 | ENTRYPOINT ["/entrypoint.sh"] 17 | CMD ["/bin/bash"] 18 | -------------------------------------------------------------------------------- /Dockerfile.xenial: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | LABEL maintainer="Zi Shen Lim " 3 | 4 | RUN set -ex; \ 5 | echo "deb [trusted=yes] http://repo.iovisor.org/apt/xenial xenial-nightly main" > /etc/apt/sources.list.d/iovisor.list; \ 6 | apt-get update -y; \ 7 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ 8 | auditd \ 9 | bcc-tools \ 10 | libelf1 \ 11 | libbcc-examples; 12 | 13 | COPY entrypoint.sh / 14 | RUN chmod +x /entrypoint.sh 15 | 16 | ENTRYPOINT ["/entrypoint.sh"] 17 | CMD ["/bin/bash"] 18 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | REPO := zlim/bcc 2 | TAGS := trusty xenial bionic 3 | 4 | UNAMER := $(shell uname -r) 5 | HOST_DIRS := /lib/modules/$(UNAMER) /usr/src/linux-headers-$(UNAMER) 6 | HOST_DIRS += /usr/src/linux-headers-$(subst -generic,,$(UNAMER)) 7 | HOST_DIRS += /etc/localtime 8 | DOCKER_VOLUMES := $(join $(HOST_DIRS),$(addprefix :,$(HOST_DIRS))) 9 | DOCKER_VOLUMES := $(addsuffix :ro,$(DOCKER_VOLUMES)) 10 | DOCKER_VOLUMES := $(addprefix -v ,$(DOCKER_VOLUMES)) 11 | 12 | #DOCKER_CAP_ADD := SYS_ADMIN 13 | #DOCKER_CAPS := $(addprefix --cap-add ,$(DOCKER_CAP_ADD)) 14 | DOCKER_CAPS := --privileged 15 | 16 | define ADD_TARGET 17 | build: build.${1} 18 | .PHONY: build.${1} 19 | build.${1}: 20 | docker build -t $(REPO):${1} -f Dockerfile.${1} . 21 | 22 | push: push.${1} 23 | .PHONY: push.${1} 24 | push.${1}: 25 | docker push $(REPO):${1} 26 | 27 | .PHONY: run.${1} 28 | run.${1}: 29 | docker run -it --rm $(DOCKER_CAPS) $(DOCKER_VOLUMES) --workdir /usr/share/bcc/ $(REPO):${1} 30 | endef #ADD_TARGET 31 | 32 | .PHONY: build push 33 | $(foreach TAG,$(TAGS),\ 34 | $(eval $(call ADD_TARGET,${TAG}))) 35 | 36 | .PHONY: run 37 | run: 38 | echo "Run targets are: $(addprefix run.,$(TAGS))" 39 | 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [bcc-docker](https://hub.docker.com/r/zlim/bcc/) is provided for user to try out [bcc](https://github.com/iovisor/bcc). 2 | 3 | From your host shell: 4 | ```bash 5 | docker run -it --rm \ 6 | --privileged \ 7 | -v /lib/modules:/lib/modules:ro \ 8 | -v /usr/src:/usr/src:ro \ 9 | -v /etc/localtime:/etc/localtime:ro \ 10 | --workdir /usr/share/bcc/tools \ 11 | zlim/bcc 12 | ``` 13 | 14 | Now, from the container shell, you can try the various pre-installed bcc tools. 15 | 16 | For examples, please refer to the [bcc tutorial](https://github.com/iovisor/bcc/tree/master/docs/tutorial.md#1-general-performance). 17 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | mount -t debugfs none /sys/kernel/debug/ 4 | exec "$@" 5 | --------------------------------------------------------------------------------