search

Home  >  Q&A  >  body text

nignx - docker内nginx 80端口被占用

[root@8f52078ea4e6 config]# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

docker容器配置的端口对应关系: 22/tcp, 0.0.0.0:80->80/tcp

天蓬老师天蓬老师2771 days ago1275

reply all(4)I'll reply

  • PHPz

    PHPz2017-04-24 16:01:58

    Not sure, but it should have nothing to do with docker's port mapping. Docker's relationship mapping is equivalent to configuring a port matching rule in the virtual box. This port will not be occupied. It is equivalent to forwarding the external port to the internal container port. .
    So your error should be that the internal port of docker is occupied. Try lsof -i :80 and see

    reply
    0
  • 高洛峰

    高洛峰2017-04-24 16:01:58

    What mirror are you using?
    If it is the official nginx, the nginx process has already been started. At this time, of course you cannot start another one on 80

    reply
    0
  • 怪我咯

    怪我咯2017-04-24 16:01:58

    The subject can enter the docker container instance of nginx and check whether nginx has been started:

    ps -ef | grep nginx
    # or
    netstat -ntpl | grep 80

    If it has already been started, there is no need to start it again

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-24 16:01:58


    You are already in the container, right? After your nginx container is started, port 80 is already up. If you are running nginx, it must show that it is occupied.

    reply
    0
  • Cancelreply