SoFunction
Updated on 2025-03-09

How to use ping and ip commands inside docker

1、ping

First solve the permission problem

Execute in docker:

apt-get update

Report an error:

E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)

Cause of the problem: Insufficient permissions, please use root user

Solution:0 means root user

		docker exec -it id /bin/bash
					// Change to		docker exec -u 0 -it id /bin/bash

ping solution

Cause of the problem

root@xxxxxxx:/# ping
bash: ping: command not found

Solution

  • Enter docker first
docker exec -u 0 -it dockerName orid /bin/bash
  • Update apt
apt-get update

Install plug-in ping

apt install iputils-ping
apt install net-tools

2、ip

Cause of the problem

root@xxxxxxx:/# ip a
bash: ip: command not found

Solution

apt update && apt install -y iproute2

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.