Access from Local Network

Can’t access to container from local network.
macOS Ventura Version 13.1 (22C65)
Docker Desktop 4.15.0 (93002)

Running MySQL server. Trying access to server from devices in local network. Spend one week on slowing problem , but still no results. Can anyone guide me please ?

And how exaxtly are you trying to access the container? The IP addresses of the containers will not be accessible from the host. You need to forward host ports to the containers.

During studding (SQL) process i’m really like Docker. But i’m beginner and need much more time for Docker understanding. So.

  • I’m run MySQL and MSSQL severs in macDocker app ,and can interact with both db throw localhost:1433 and lockalhost:3306
  • But can’t connect to db from other devices from local network ( another words from wi-fi )
  1. I was change network in Docker setting on 192.168.1.0/24 (default getaway in local network 192.168.1.1)
  2. I’m crate docker network with :
docker network create \
  --driver=bridge \
  --subnet=192.168.1.0/16 \
  --ip-range=192.168.2.0/24 \
  --gateway=192.168.2.1 \
  br0
  1. Bind container to created bridge

PS. sorry for my noob talk :worried:

I can only repeat myself :slight_smile:

Docker Desktop runs containers in a virtual machine. Doesn’t matter how you change the IP address of the containers, you will not be able to access it from the host or other devices. You need port forwarding.

docker run -d -p 8888:80 --name httpd httpd:2.4

It would run HTTPD and make it available on port 8888 from the host and if your firewall allows it, you can access it from other devices. The port number on the right side is the port on which the service inside the container is listening.

Got it .
When trying do same with MySQL
docker run --name -p 8888:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
receiving error :
docker: Error response from daemon: pull access denied for 8888, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
It’s trying pull it from hub-repo ?

You have no container name after --name. That is the problem.

it’s work! On other devices i connect to mac’s IP with selected ports . :saluting_face:
@rimelek Thanks a lot for help ! Hope this post help confused beginners like me :sweat_smile:

Yes, you need to use the public (on a specific network) IP address of the Docker host machine from remote devices.