I’m running a dockurr/samba Docker container on my Apple M2 Pro machine. I can successfully access the Samba share from the host machine (using Finder/Connect to Server), but I’m unable to connect to it from other devices on the same local network (e.g., another computer, Android TV).
Here’s my Docker Compose configuration:
samba:
image: dockurr/samba
container_name: samba
hostname: samba
environment:
NAME: ${SAMBA_NAME}
USER: ${SAMBA_USER}
PASS: ${SAMBA_PASS}
ports:
- ${SAMBA_PORT_445}:445
volumes:
- ${PATH_TO_MEDIA_FOLDER}:/storage
I’ve tried the following troubleshooting steps:
Verified firewall rules: Ensured that the firewall on my host machine allows incoming connections on port 445.
Restarted services: Restarted Docker and the Samba service within the container.
Checked network connectivity: Confirmed that both the host machine and the other devices are on the same network.
I would greatly appreciate any assistance in resolving this connection issue.
2
Answers
You need to expose the relevant ports on the host IP. You can do that using the -p switch to docker run.
For example:
The above will map port 445 on the local host to the docker container. Make sure nothing else is listening on the same port.
Docker documentation about bridge networking(https://docs.docker.com/engine/network/drivers/bridge/) :
For Docker, a bridge network uses a software bridge which allows containers connected to the same bridge network to communicate, while providing isolation from containers which are not connected to that bridge network.
Docker documentation about host networking (https://docs.docker.com/engine/network/drivers/host/) :
If you use the host network driver for a container, that container’s network stack is not isolated from the Docker host. For instance, if you run a container which binds to port 445 and you use host networking, the container’s application will be available on port 445 on the host’s IP address.
If you want to deploy multiple containers connected between them with a private internal network use bridge networking. If you want to deploy a container connected to the same network stack as the host (and access the same networks as the host) use host networking. And, if you want to publish some ports, run the container with the –publish or -p option, such as -p 445:445.