Skip to content

Containers cannot communicate with each other when using an internal network #47229

@iam-Justin

Description

@iam-Justin

Description

version: "3.8"

networks:
  database:
    driver: bridge
    internal: true
    ipam:
      driver: default
      config:
      - subnet: 172.16.240.0/24

services:
  nginx:
    image: nginx
    container_name: nginx
    networks:
      #frontend:
      #backend:
      database:

  debug:
    image: curlimages/curl
    container_name: debug
    command: "sh"
    stdin_open: true
    tty: true
    networks:
      #frontend:
      #backend:
      database:

I tested on openSUSE and fedora systems. On the openSUSE system, the ping goes through but not the port, and on the Fedora system it doesn't even ping through.

Reproduce

docker compose up -d
docker exec debug ping nginx
docker exec debug curl -Iv nginx

connect to 172.16.240.2 port 80 from 172.16.240.3 port 56700 failed: Operation timed out

  • Failed to connect to nginx port 80 after 132845 ms: Couldn't connect to server

Expected behavior

docker exec debug curl -Iv nginx

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 172.16.240.2:80...
* Connected to nginx (172.16.240.2) port 80 (#0)
> HEAD / HTTP/1.1
> Host: nginx
> User-Agent: curl/7.88.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: nginx/1.25.3
< Date: Fri, 26 Jan 2024 03:49:26 GMT
< Content-Type: text/html
< Content-Length: 615
< Last-Modified: Tue, 24 Oct 2023 13:46:47 GMT
< Connection: keep-alive
< ETag: "6537cac7-267"
< Accept-Ranges: bytes
< 
  0   615    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host nginx left intact
HTTP/1.1 200 OK
Server: nginx/1.25.3
Date: Fri, 26 Jan 2024 03:49:26 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 24 Oct 2023 13:46:47 GMT
Connection: keep-alive
ETag: "6537cac7-267"
Accept-Ranges: bytes

docker version

Client: Docker Engine - Community
 Version:           25.0.1
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        29cf629
 Built:             Tue Jan 23 23:11:29 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.1
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       71fa3ab
  Built:            Tue Jan 23 23:09:46 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.27
  GitCommit:        a1496014c916f9e62104b33d1bb5bd03b0858e59
 runc:
  Version:          1.1.11
  GitCommit:        v1.1.11-0-g4bccb38
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client: Docker Engine - Community
 Version:    25.0.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 2
 Server Version: 25.0.1
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 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: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: a1496014c916f9e62104b33d1bb5bd03b0858e59
 runc version: v1.1.11-0-g4bccb38
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.6-300.fc39.x86_64
 Operating System: Fedora Linux 39 (Server Edition)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 3.809GiB
 Name: localhost.localdomain
 ID: 964f3733-ef63-4107-a6e5-df4333d1894a
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

Metadata

Metadata

Assignees

Labels

area/networkingNetworkingkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.status/0-triageversion/25.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions