RNK
RNK

Reputation: 5792

Add tcpdump docker image with base image node:10.0.0

How can I add tcpdump package in Dockerfile if the base image is node:10.0.0

Dockerfile:

FROM node:10.0.0
EXPOSE $SERVICE_PORT
USER node
RUN mkdir -p /home/node/
WORKDIR /home/node/
COPY package.json /home/node/
RUN npm install
COPY . /home/node/
CMD ["npm", "run", "staging"]

I want to trace the traffic in this container.

Upvotes: 0

Views: 3769

Answers (2)

BMitch
BMitch

Reputation: 265150

It is unnecessary to modify your image to access the network of the container. You can run a second container in the same network namespace:

docker run -it --net container:${container_to_debug}  nicolaka/netshoot 

From there, you can run tcpdump and a variety of other network debugging tools and see the traffic going to your other container. To see all the tools included in netshoot, see the github repo: https://github.com/nicolaka/netshoot

Upvotes: 2

Efrat Levitan
Efrat Levitan

Reputation: 5632

you base image is debian based, therefore use apt-get as your package manager. add to your dockerfile the following instructions:

USER root 
RUN apt-get update -y; exit 0
RUN apt-get install tcpdump -y

explanation:

USER root - apt-get requires root permissions.

RUN apt-get update -y; exit 0 - i am adding exit 0 to tell docker i want to keep the build, even if apt-get couldn't get all of its mirror files

RUN apt-get install tcpdump -y - installation of the package.

Upvotes: 0

Related Questions