V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
documentzhangx66
V2EX  ›  Docker

如何对一个 docker 实例进行 netstat ?

  •  
  •   documentzhangx66 · 2022-11-09 21:56:32 +08:00 · 1552 次点击
    这是一个创建于 505 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Nextcloud 有一个 All-In-One ( AIO )的 docker 镜像。

    安装方式在这里: https://github.com/nextcloud/all-in-one

    但安装方式的例子,只处理了 3 个端口映射: 80 、8080 、8443

    没有涉及到 https 443 端口。

    而浏览器在访问 80 端口时,服务端回复让浏览器重定位到 https ,也就是 443 端口。

    我怀疑官方搞错端口了,想进这个镜像进行

    netstat -nlap | grep "LISTEN" | grep "443"

    但进入镜像后,我发现里面啥工具都没有,如果要安装工具,需要解决一大堆包依赖问题。

    请问有没有什么快捷的办法,对该镜像的实例,进行 netstat ?

    11 条回复    2022-11-10 22:29:37 +08:00
    snowish
        1
    snowish  
       2022-11-09 22:24:49 +08:00
    你可以安装 net-tools ,
    例如 Ubuntu/Debian 用这个命令安装:
    apt install -y net-tools
    很多镜像用 Alpine ,用下面这个命令安装:
    apk install net-tools
    也许你还需要用 sed 命令把源改为国内的。
    leonshaw
        2
    leonshaw  
       2022-11-09 22:44:44 +08:00
    nsenter
    kokutou
        3
    kokutou  
       2022-11-09 23:01:25 +08:00 via Android
    看文档❎
    上 v2 问✅
    kiritoyui
        4
    kiritoyui  
       2022-11-10 06:57:06 +08:00 via iPhone
    @snowish 不是 apk add xxx 么?
    kiritoyui
        5
    kiritoyui  
       2022-11-10 07:03:44 +08:00 via iPhone
    After the initial startup, you should be able to open the Nextcloud AIO Interface now on port 8080 of this server.
    E.g. https://ip.address.of.this.server:8080

    说了访问 8080 端口
    Privileges
        6
    Privileges  
       2022-11-10 09:19:24 +08:00 via Android
    apk 或者 apt 装一下就好了
    documentzhangx66
        7
    documentzhangx66  
    OP
       2022-11-10 11:52:55 +08:00
    @kiritoyui

    能麻烦你再看一下原题中的文字描述吗?

    我怀疑官方搞错端口了,因为服务端回复让浏览器重定位到 https ,也就是 443 端口。
    documentzhangx66
        8
    documentzhangx66  
    OP
       2022-11-10 11:53:37 +08:00
    @snowish
    @Privileges

    麻烦各位老哥,试试你们说的 apt 装一下,就知道我为啥要专门开个帖子提问了。
    Privileges
        9
    Privileges  
       2022-11-10 13:56:35 +08:00
    @documentzhangx66

    你是不是进错 shell 了,docker exec -it name bash 进入后 apt 安装 net-tools 一切正常。
    Privileges
        10
    Privileges  
       2022-11-10 14:37:23 +08:00
    创建并进入容器后,apt 提示未找到,我只触发过一次,但切换到 bash 后就正常了。

    后面删除容器挂载缓存,重新创建容器也没再此遇到过。

    证明我确实去试着装了一下 https://imgur.com/oo7Si2P
    kiritoyui
        11
    kiritoyui  
       2022-11-10 22:29:37 +08:00 via iPhone
    @documentzhangx66

    After the initial startup, you should be able to open the Nextcloud AIO Interface now on port 8080 of this server.
    E.g. https://ip.address.of.this.server:8080

    If your firewall/router has port 80 and 8443 open and you point a domain to your server, you can get a valid certificate automatically by opening the Nextcloud AIO Interface via:
    https://your-domain-that-points-to-this-server.tld:8443


    我不觉得我的理解有啥问题,官网文档明明让你访问 8080 ,或者 8443 ,你非要访问 80
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1210 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:15 · PVG 07:15 · LAX 16:15 · JFK 19:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.