l'm using official images of PHP7, my docker start command: docker run -p 9000:9000 --name php -v $site_path:/var/www/html/ --privileged=true -d php:php72

$site_path is a directory that saving my php code, then l was into the docker container, use php server.php then got the warning above.

l also tried to run script without 9000 port like 9001, then script worked, but l can't connect to the server with my JS

l tried to use php server.php on my local environment(not in docker) and it worked, JS connected it successfully, too.

1 Answers

CFrei On

You have your port 9000 and 9001 already blocked by running containers or local software.

docker ps shows you all running containers and the port they block. If not needed, remove these container with docker rm [-f] <name>. If on Linux, you can check what else is running locally on port 9000/9001 by looking at netstat -lnp. Stop the processes, too.

Please note that you don't need to change the port in your container, if you want to try a new target port on host. You can also do: -p9002:9000, if you want a service accessible by port 9002 on your localhost.