【Docekr学习遇到的坑】

​​

在这里插入图片描述

坑一

坑: 学习docker网络时,进入tomcat容器发现ip addr不可以使用

[root@VM-16-15-centos ~]# docker run -it --name tomcat04  tomcat  /bin/bash 
root@828d1e76b08d:/usr/local/tomcat# ip addr 
bash: ip: command not found


原因: 通过查找发现,我们下载的tomcat镜像是精简版的,利用这个镜像打开一个容器,发现没有ip addr命令。所以导致错误


解决办法:
先进入docker容器中

docker exec -it xxx /bin/bash

执行ip addr 命令

root@828d1e76b08d:/usr/local/tomcat# apt update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]                              
Get:3 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [154 kB]
Get:4 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]                      
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8182 kB]   

执行 apt install -y iproute2

root@828d1e76b08d:/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


测试

root@828d1e76b08d:/usr/local/tomcat# 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
108: eth0@if109: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group >default 
  link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
  inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
     valid_lft forever preferred_lft forever

在这里插入图片描述

坑二

坑: 在学习docker网络部署时,进入tomcat容器发现ping命令,不存在,原因如上,所以需要进行ping命令的安装

root@828d1e76b08d:/usr/local/tomcat# ping
bash: ping: command not found

先进入docker容器中

docker exec -it xxx /bin/bash

执行apt-get update

root@828d1e76b08d:/usr/local/tomcat# apt-get update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease
Reading package lists... Done

执行apt install iputils-ping

root@828d1e76b08d:/usr/local/tomcat# apt install iputils-ping
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
 iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 38 not upgraded.
Need to get 49.8 kB of archives.
After this operation, 116 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 iputils-ping amd64 >3:20210202-1 [49.8 kB]
Fetched 49.8 kB in 2s (28.4 kB/s)                           
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package iputils-ping.
(Reading database ... 12909 files and directories currently installed.)
Preparing to unpack .../iputils-ping_3%3a20210202-1_amd64.deb ...
Unpacking iputils-ping (3:20210202-1) ...
Setting up iputils-ping (3:20210202-1) ...
  • 11
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小呆鸟_coding

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值