If you start your container and you get an error such as this one, then it does only mean that you already have a service (or another Docker container) running on that port.
1
Ports are not available: listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket
2
in a way forbidden by its access permissions
Copied!
"Localhost" along with the port of a container are the unique identifier in Docker.
This means, that a container cannot be started if the port is already blocked.
To fix this please use these steps.
1. Verify Docker Containers
Check all your existing Docker containers and remove the one, that uses the port that you need for your new container.
1
# show ALL containers
2
dockerps -a
3
4
# remove our old container
5
dockerrm -f (container_name)
Copied!
2. Verify other services
If no Docker container uses your port, it might be a native service or another application.
For example, a locally installed MySQL instance might already block our Port 3306, so Docker cannot use it.