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 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘