Docker查找容器ip报错
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ip addr": executable file not found in $PATH: unknown
解决方案:
#进入容器内部,执行apt-get update && apt update && apt install -y iproute2 [root@aliyun ~]# docker exec -it tomcat01 /bin/bash root@1a8bddcb0fdd:/usr/local/tomcat# apt-get update Hit:1 http://security.debian.org/debian-security bullseye-security InRelease Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB] Hit:3 http://deb.debian.org/debian bullseye-updates InRelease Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB] Ign:4 http://deb.debian.org/debian bullseye/main amd64 Packages Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB] Fetched 3394 kB in 3min 32s (16.0 kB/s) Reading package lists... Done root@1a8bddcb0fdd:/usr/local/tomcat# apt install -y iproute2 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: libatm1 libbpf0 libcap2 libcap2-bin libelf1 libmnl0 libpam-cap libxtables12 Suggested packages: iproute2-doc The following NEW packages will be installed: iproute2 libatm1 libbpf0 libcap2 libcap2-bin libelf1 libmnl0 libpam-cap libxtables12 0 upgraded, 9 newly installed, 0 to remove and 36 not upgraded. Need to get 1394 kB of archives. ···
在此执行命令查看容器ip
[root@aliyun ~]# docker exec -it tomcat01 ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 81: eth0@if82: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 172.18.0.2/16 brd 172.18.255.255 scope global eth0 valid_lft forever preferred_lft forever
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律