Laradock NGINX cannot start service

997 views Asked by At

I had a working laradock docker container and wanted to add some services, when I tried to rebuild I get the following error:-

ERROR: for laradock_nginx_1 Cannot start service nginx: Ports are not available: listen tcp 0.0.0.0:81: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

I have tried to list services using port 81 but lsof -i TCP:81 returned no results so i tried listing everything with lsof -i which returned

node     23 chris   18u  IPv4   1034      0t0  TCP localhost:38187 (LISTEN)
node     23 chris   21u  IPv4   1052      0t0  TCP localhost:38187->localhost:49786 (ESTABLISHED)
node     77 chris   18u  IPv4  18626      0t0  TCP localhost:49786->localhost:38187 (ESTABLISHED)
node     86 chris   18u  IPv4  22566      0t0  TCP localhost:49788->localhost:38187 (ESTABLISHED)
node    106 chris   19u  IPv4   1057      0t0  TCP localhost:38187->localhost:49788 (ESTABLISHED)

I thought it may be conflicting with my old setup so I have pruned everything and started from fresh with the latest release of docker desktop and laradock, still getting the same error and now i'm stuck and don't even have my old container to fall back on.

What can be causing this error?

2

There are 2 answers

0
matic1123 On BEST ANSWER

If anyone has the same issue user binding the host port 81 did not have enough permissions quickest fix was to change docker's host port inside port binding to above 1024 (we used 8080) and it worked.

0
abdulalim On

Docker nginx port issue: By default ubuntu install apache which run in 80 port. so just stop it. This can happen also for nginx. So follow same process.

sudo /etc/init.d/apache2 stop

nginx:
    restart: unless-stopped
    build:
      context: .
      dockerfile: ./docker/nginx/Dockerfile
    ports:
      - '80:80'
    volumes:
      - static_volume:/home/pos/static/
      - ./docker/nginx/development:/etc/nginx/conf.d
    depends_on:
      - backend