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
. 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.