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.
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 ?
it’s work! On other devices i connect to mac’s IP with selected ports . @rimelek Thanks a lot for help ! Hope this post help confused beginners like me
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..
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.
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.
It is impossible that the exact command you quoted above this error message was used.
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:
I appreciate you sharing those resources. I am a super noob . 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.
It actually is very simple. You managed to create at least on mysql container where you published the container port 3306 to the host port 8888. Thus, you have forwarded host port 8888 to container port 3306.