Problem with Dockerfile causes "curl (56) Recv failure"

I am trying to create a docker container from a nginx Dockerfile and am having problems. First I performed the following test:

# docker run --name test -p 8080:80 -d nginx:latest
# curl localhost:8080

This works without problems. Now when I am trying to build my dockerfile from a ready container my problems start. Below is my project:

web/Dockerfile

FROM nginx:latest
MAINTAINER [email protected]

LABEL Description="Project Frontend"

EXPOSE 80

VOLUME ["/usr/share/nginx/html"]

docker-compose.yml

version: '3'
services:
  web:
    build: web
    ports:
      - "8080:80"
    container_name: "project_frontend"
    volumes:
      - /app/project_frontend:/usr/share/nginx/html
    command: /bin/bash
    tty: true

When I now try to use the "curl" command the result is as follows:

curl: (56) Recv failure: Connection reset by peer

Upvotes: 0

Views: 246

Answers (1)

Adiii
Adiii

Reputation: 59966

As mentioned by @David, you are not starting nginx at all, as this line in docker-compose will override the CMD of Dockerfile.

command: /bin/bash

replace the command with

command: ["nginx", "-g", "daemon off;"]

or move this Dockerfile

CMD ["nginx", "-g", "daemon off;"]

Or you the Nginx base image will take care of it if you did not mention at all.

Upvotes: 1

Related Questions