在nginx日志中记录的Docker-compose up问题端口443(98:地址已在使用中)错误

时间:2019-09-27 08:07:07

标签: docker docker-compose

尝试启动docker时遇到以下错误:

2019/09/27 07:53:33 [emerg] 18#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2019/09/27 07:53:33 [emerg] 18#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2019/09/27 07:53:33 [emerg] 18#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2019/09/27 07:53:33 [emerg] 18#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2019/09/27 07:53:33 [emerg] 18#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2019/09/27 07:53:33 [emerg] 18#0: still could not bind()

当我尝试访问将在nginx上运行的应用程序时,还会记录以下错误:

2019/09/27 07:55:54 [error] 11#0: *50 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.10.5.254, server: checkout.servername.docker, request: "GET / HTTP/1.1", upstream: "http://192.168.99.1:3000/", host: "checkout.servername.docker.uk"

以下是我的docker-compose.yml文件中的一部分:

  varnish:
    build: ./docker/varnish_nginx
    links:
      - apache
    volumes:
      - ./docker/varnish_nginx/varnish/default.vcl:/etc/varnish/default.vcl
      - ./docker/varnish_nginx/varnish/magento_mobile_detect.vcl:/etc/varnish/magento_mobile_detect.vcl
      - ./docker/varnish_nginx/varnish/varnish.params:/etc/varnish/varnish.params
      - ./docker/varnish_nginx/varnish/start.sh:/start-varnish.sh
      - ./logs/varnish/:/var/log/varnish
      - ./docker/varnish_nginx/nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./docker/varnish_nginx/nginx/ssl/levosoft_docker.csr:/etc/nginx/ssl/levosoft_docker.csr
      - ./docker/varnish_nginx/nginx/ssl/levosoft_docker.key:/etc/nginx/ssl/levosoft_docker.key
      - ./docker/varnish_nginx/nginx/ssl/levosoft_docker.pem:/etc/nginx/ssl/levosoft_docker.pem
      - ./logs/nginx/:/var/log/nginx
      - ./docker/varnish_nginx/nginx/start.sh:/start-nginx.sh
    networks:
      widgets:
        ipv4_address: 172.10.1.8
    ports:
      - 80:80
      - 443:443
      - 6082:6082

1 个答案:

答案 0 :(得分:0)

如错误所示,另一个进程已在使用端口443。

要验证并找到使用它的过程,请运行以下命令:

sudo netstat -tulpn | grep 443

输出:

$ sudo netstat -tulpn | grep 443
tcp6       0      0 :::443                  :::*                    LISTEN      26951/docker-proxy

现在,您已经确定了该进程,您应该将其关闭,然后重新启动失败的nginx Docker容器。