简体   繁体   English

Docker 映像失败 - 使用了端口 8080

[英]Docker image failed - port 8080 used

I'am trying to build docker containers on my MAC but I'm getting an error:我正在尝试在我的 MAC 上构建 docker 容器,但出现错误:

ERROR: for myapp_app-nginx_1 Cannot start service app-nginx: Ports are not available: listen tcp 0.0.0.0:80: bind: address already in use错误:对于 myapp_app-nginx_1 无法启动服务 app-nginx:端口不可用:侦听 tcp 0.0.0.0:80:绑定:地址已在使用中

I tried everything.我尝试了一切。 I don't have nginx globally installed so i don't know what is the problem.我没有全局安装 nginx,所以我不知道是什么问题。

This is my docker-compose.yml:这是我的 docker-compose.yml:

version: '3.5'

services:
  app-nginx:
    build:
      context: .
      dockerfile: .docker/dev/nginx/Dockerfile
      args:
        PHP_HOSTNAME: app-php
    volumes:
      - ./frontend:/usr/share/nginx/html:cached
    networks:
      - myapp-io
    ports:
      - 80:80
    depends_on:
      - app-php

  app-php:
    build:
      context: .
      dockerfile: .docker/dev/php/Dockerfile
    volumes:
      - .:/var/www/html:cached
    networks:
      - myapp-io
    depends_on:
      - app-db
    command:
      - /bin/sh
      - -c
      - |
        composer install
        php bin/console myapp:db:init-or-update
        php bin/console doctrine:migrations:migrate
        php-fpm

  app-db:
    image: postgres:10-alpine
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=abc
      - POSTGRES_PASSWORD=abc
    volumes:
      - db-volume:/var/lib/postgresql/data:cached
    networks:
      - uhub-io
    ports:
      - 5432:5432

  app-node:
    image: node:12.10-buster
    working_dir: /home/node/app
    volumes:
      - ./frontend:/home/node/app:cached
    networks:
      - myapp-io
    command:
      - /bin/sh
      - -c
      - |
        [ -d node_modules/.bin ] || npm install
        [ -f dist/apps/myapp-app/index.html ] || npm run build:docker

volumes:
  db-volume:

networks:
  myapp-io:
    name: myapp-io

Update: I run command netstat -an |更新:我运行命令netstat -an | grep LISTEN and got: grep LISTEN并得到:

image图片

What should I do?我该怎么办? I am new on mac.我是 mac 新手。

It's not port 8080, it's 80, and you must have something listening on that port.它不是端口 8080,而是 80,并且您必须在该端口上侦听某些内容。

For example, use netstat -an | grep LISTEN例如,使用netstat -an | grep LISTEN netstat -an | grep LISTEN to check every process that it's listening, and then find out which one is using port 80. netstat -an | grep LISTEN检查它正在侦听的每个进程,然后找出哪个进程正在使用端口 80。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM