docker / cli

The Docker CLI
Apache License 2.0
4.93k stars 1.93k forks source link

API from container seem can not get response #5000

Closed fukemy closed 7 months ago

fukemy commented 7 months ago

Description

Hi, I am building FreePBX inside Docker from https://github.com/tiredofit/docker-freepbx. I am success to register the trunk, when test the trunk I see it's only send and no receive like below:

Ảnh màn hình 2024-04-10 lúc 15 29 53

Here is the log from my Asterisk:

[2024-04-10 08:29:48] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #18)
[2024-04-10 08:30:08] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #19)
[2024-04-10 08:30:28] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #20)
[2024-04-10 08:30:48] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #21)
[2024-04-10 08:31:08] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #22)
[2024-04-10 08:31:28] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #23)
[2024-04-10 08:31:48] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #24)
[2024-04-10 08:32:08] NOTICE[9390]: chan_sip.c:16046 sip_reg_timeout:    -- Registration for '234b80b8@sip.nexmo.com' timed out, trying again (Attempt #25)

It's seem the docker can not connect to internet? I am new with Docker, here is our container detail

CONTAINER ID   IMAGE                  COMMAND            CREATED          STATUS                           PORTS                                                                                                                                                                                            NAMES
9f46aab63ab0   tiredofit/freepbx      "/init"            21 minutes ago   Up 21 minutes                    443/tcp, 4445/tcp, 4569/tcp, 0.0.0.0:5060->5060/udp, 5061/tcp, 5161/tcp, 8001/tcp, 8003/tcp, 8008-8009/tcp, 8025/tcp, 10050/tcp, 0.0.0.0:5160->5160/udp, 18000-20000/udp, 0.0.0.0:2000->80/tcp   crazy_williamson

Reproduce

  1. install docker-freepbx
  2. register sip trunk
  3. see the result like Description

Expected behavior

I want to see our asterisk success to registering SIP trunk

docker version

Client:
 Cloud integration: v1.0.35+desktop.11
 Version:           25.0.3
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        4debf41
 Built:             Tue Feb  6 21:13:26 2024
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.28.0 (139021)
 Engine:
  Version:          25.0.3
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       f417435
  Built:            Tue Feb  6 21:14:22 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    25.0.3
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1-desktop.4
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.6-desktop.1
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.24
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-debug
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.22
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.0.1
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.5.0
    Path:     /Users/vedaxm1/.docker/cli-plugins/docker-scout

Server:
 Containers: 2
  Running: 1
  Paused: 0
  Stopped: 1
 Images: 2
 Server Version: 25.0.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.6.16-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 8
 Total Memory: 7.658GiB
 Name: docker-desktop
 ID: f2b3d69e-d76c-427f-8306-d49791d8cb5f
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Additional Info

let see the request content: Call flow for 1545a1a54cc9cefa1f481a8f2a9f9cb8@172.17.0.2 (Color by Request/Response) │REGISTER sip:sip.nexmo.com SIP/2.0 172.17.0.2:5160 216.147.4.2:5060 216.147.4.1:5060 │Via: SIP/2.0/UDP 172.17.0.2:5160;branch=z9hG ──────────┬───────── ──────────┬───────── ──────────┬─────────│K00d1ec17;rport ▒ 08:25:20.038289 │ REGISTER │ │ │Max-Forwards: 70 ▒ +4.000942 │ ──────────────────────────> │ │ │From: sip:234b80b8@sip.nexmo.com;tag=as189 │ 08:25:24.039231 │ REGISTER │ │ │735 │ +4.001929 │ ────────────────────────>>> │ │ │To: sip:234b80b8@sip.nexmo.com │ 08:25:28.041160 │ REGISTER │ │ │Call-ID: 1545a1a54cc9cefa1f481a8f2a9f9cb8@17 │ +0.518084 │ ────────────────────────>>> │ │ │17.0.2 │ 08:25:28.559244 │ REGISTER │ │ │CSeq: 105 REGISTER │ +0.501907 │ ──────────────────────────> │ │ │Supported: replaces, timer │ 08:25:29.061151 │ REGISTER │ │ │User-Agent: FPBX-15.0.37.4(17.9.3) │ +0.999491 │ ────────────────────────>>> │ │ │Expires: 120 │ 08:25:30.060642 │ REGISTER │ │ │Contact: sip:s@172.17.0.2:5160 │ +1.999446 │ ────────────────────────>>> │ │ │Content-Length: 0 │ 08:25:32.060088 │ REGISTER │ │ │ │ +4.003024 │ ────────────────────────>>> │ │ │ │ 08:25:36.063112 │ REGISTER │ │ │ │ +3.999811 │ ────────────────────────>>> │ │ │ │ 08:25:40.062923 │ REGISTER │ │ │ │ +3.997286 │ ────────────────────────>>> │ │ │ │ 08:25:44.060209 │ REGISTER │ │ │ │ +4.000228 │ ────────────────────────>>> │ │ │ │ 08:25:48.060437 │ REGISTER │ │ │ │ +0.512831 │ ────────────────────────>>> │ │ │ │ 08:25:48.573268 │ REGISTER │ │ │ │ │ ──────────────────────────> │ │ │ │ Esc Calls List Enter Raw Space Compare F1 Help F2 SDP F3 RTP F4 Extended s Compressed F6 Raw c Colour by 9 Increase

akerouanton commented 7 months ago

Hi @fukemy,

AFAICT this is not a bug within the Engine itself, which is what this issue tracker is made for. It's not intended to ask for help. For that, you should instead head towards the Docker Forum, community Slack, etc... See here: https://www.docker.com/community/get-involved/. As such, I'll close this ticket.

But first, I'm pretty confident what you're seeing is a NAT issue. Docker Desktop is NATing connections to/from the VM. Here, 172.17.0.2 is an IP address assigned by the Engine to a container, so it's not reachable outside of DD VM. You need to either configure your software to use the host IP address, or use host networking (beta feature released in v4.29, see: https://docs.docker.com/network/drivers/host/#docker-desktop).

fukemy commented 6 months ago

hi @akerouanton , thanks you for your explain, I know this but can I ask you other problem: If I am using --net=host so all the udp port will be ignore. But I want to use it's for SIP calling, can you give me some advices? Thanks

fukemy commented 6 months ago

@akerouanton, I tried to run docker run ... --network=host..., then I found this issue still occur

Ảnh màn hình 2024-04-11 lúc 11 29 56