Port forward not working on a macOS installation but works on others

Ok, we have a macOS laptop (one of the latest MacBook Pro with the touchID touch bar) where port forwarding does not work. Our tests are fairly simple.

1.- We bringup a container for MariaDB and port forward 3303 to 3306 (docker run --name some-mariadb2 -p 127.0.0.1:3303:3306 -e MYSQL_ROOT_PASSWORD=my_password -d mariadb:10.2.22-bionic)

2.- We attempt to telnet to port 3303 on localhost

On all laptop we see the container running with the proper port forward

{13:42}[2.5.0]~/Documents➭ docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
a6c53bd9df24        mariadb:10.2.22-bionic   "docker-entrypoint.s…"   2 hours ago         Up 2 hours          0.0.0.0:3303->3306/tcp   some-mariadb2

On the laptop where it’s working when we telnet we get:

{13:49}[2.5.0]~ ➭ telnet localhost 3303
Trying ::1...
Connected to localhost.
Escape character is '^]'.
p
5.5.5-10.2.22-MariaDB-1:10.2.22+maria~bionic
                                            Z3-)&!o2���IVW1-0EM3U5Hmysql_native_password^]

Which is what we are expecting. However on the laptop that it’s not working we get:

$ telnet localhost 3303
Trying ::1...
Connected to localhost.
Escape character is '^]'.

And it just hangs there.

We looked at the macOS firewall (turned-off), turned off any running application that could be suspect.

I’m out of ideas on that one and maybe someone here has something we can try.

Thanks.

1 Like

Thanks for raising. I’m getting the same issue - I suspect there is a Docker for Mac problem here, probably with the proxy that exposes ports. This is with the stable build, Version 2.0.0.3 (31259).

I’ve raised a ticket on the testcontainers-java project (which I’m a maintainer of) for visibility, setting out what I’ve tried and observed so far: https://github.com/testcontainers/testcontainers-java/issues/1623

I don’t think this is a Testcontainers-specific issue at all though, and believe there is most likely a bug in Docker for Mac.

It seems that this is a known bug and a fix is in the pipeline. For now, the edge build of Docker for Mac works.

More info: https://github.com/docker/for-mac/issues/3487#issuecomment-509176608

Nice. Will see if we can give it a shot.

I’m getting this issue as well. My version is 2.2.0.5. Doesn’t seemed to be fixed yet…

Hello! In case of someone has not yet solved this issue, this is my workaround:
Happens the docker daemon is not actually running inside of Mac itself like in a Linux box, but inside of a VM (since I installed it from [home]brew, it is running in a VirtualBox instance), so I changed the networking settings of that VM to use the “bridge adapter”, I restarted the VM, then I restarted the docker containers, and now I can access to my containers by addressing them to the IP of their VM. From Mac, the command still docker works.

1 Like

thank you very much, this solved the problem for me

Hello, can you tell us how exactly you set the VM to use the “bridge adapter”? I can’t find this option anywhere.

➜ ~ docker version
Client:
 Cloud integration: v1.0.29
 Version:      20.10.21
 API version:    1.41
 Go version:    go1.18.7
 Git commit:    baeda1f
 Built:       Tue Oct 25 18:01:18 2022
 OS/Arch:      darwin/arm64
 Context:      default
 Experimental:   true
Server: Docker Desktop 4.15.0 (93002)
 Engine:
 Version:     20.10.21
 API version:   1.41 (minimum version 1.12)
 Go version:    go1.18.7
 Git commit:    3056208
 Built:      Tue Oct 25 17:59:41 2022
 OS/Arch:     linux/arm64
 Experimental:   false
 containerd:
 Version:     1.6.10
 GitCommit:    770bd0108c32f3fb5c73ae1264f7e503fe7b2661
 runc:
 Version:     1.1.4
 GitCommit:    v1.1.4-0-g5fd4c4d
 docker-init:
 Version:     0.19.0
 GitCommit:    de40ad0

Did you solve this problem ?