douchou8935 2019-05-05 12:12
浏览 136

Dcoker中的PHP,警告:socket_bind():无法绑定地址[98]:第28行的/var/www/html/websocket/server.php中已经使用的地址

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条回答 默认 最新

  • doutale7115 2019-05-05 13:54
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题