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 ?

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 )
  • I was change network in Docker setting on 192.168.1.0/24 (default getaway in local network 192.168.1.1)
  • 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 \
    
  • Bind container to created bridge
  • PS. sorry for my noob talk :worried:

    rimelek:

    The IP addresses of the containers will not be accessible from the host. You need to forward host ports to the containers.

    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 ?

    I have been struggling with this same thing. I have tried copying and pasting these commands and have had no luck. I have read this thread like 15 times hoping to find something I didn’t notice.

    docker run --name -p 8888:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

    do I need to put my actual credentials here? I know it’s a dumb question but this is all new and noticed somethings are capitalized and others aren’t. Thank you in advance

    Your command works fine for me. Though, you might want to use a volume or bind a host folder into the container folder where the database data is persisted. Otherwise, you will lose all data when the container is removed.

    Thus said, please share the exact error message you see in the container logs..

    erikgzlz84:

    docker run --name HA -p 8888:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

    docker: Error response from daemon: Invalid container name (–HA), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed

    erikgzlz84:

    docker run --name HA -p 8888:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

    docker: Error response from daemon: Conflict. The container name “/HA” is already in use by container “f408a86b95f18a131a2cc50b972903bc1f71d4aa997e98bf76397524d7a98a16”. You have to remove (or rename) that container to be able to reuse that name.

    erikgzlz84:

    docker: Error response from daemon: Invalid container name (–HA), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed

    It is impossible that the exact command you quoted above this error message was used.

    erikgzlz84:

    Conflict. The container name “/HA” is already in use by container “… ”. You have to remove (or rename) that container to be able to reuse that name.

    A name has to be unique, when a container with the same name exists, of course it won’t be able to create a new container using the same name. You should find containers with the names you created using docker ps -a.

    Docker makes more fun, if you know what you are doing. Here are recommended links to learn the basics and concepts:

  • General “self-paced” training about containers: Training Materials
  • @rimelek’s tutorials: Welcome to Learn Docker’s documentation! — Learn Docker documentation
  • What is a container (docker docs): What is a container? | Docker Docs
  • I appreciate you sharing those resources. I am a super noob :sweat_smile:. I really just wanted to run Home Assistant on my Mac server and saw the wonderful potential with Docker. I am pretty tech savvy and grasp the concept here, but to be honest this is a pain just to get one container to talk to the other devices on my network. I successfully installed Home Assistant in this container but clearly this seems like more work then I bargained for to have this container do a simple port forwarding. I guess I will have to revisit this when I have time or bite the bullet and just run a VM on my server. Thank you again for your time.