docker-compose up not running app correctly

Discussão em 'Angular' iniciado por user6680, Dezembro 10, 2024.

  1. user6680

    user6680 Guest

    I'm very new to docker. I have a mean stack app that and have configured the dockerfile for frontend and backend as you can see below. When I run docker-compose up it appears to finish, but when I go to localhost I'm greeted with this instead of my mean stack app.

    [​IMG]

    I'm not really sure why, but appreciate any help with this.

    backend Dockerfile

    FROM node

    MAINTAINER Phil

    WORKDIR /src

    COPY . /src

    RUN npm install

    RUN npm install -g nodemon

    EXPOSE 3000

    CMD ["npm", "start"]


    frontend Dockerfile

    FROM nginx
    MAINTAINER Phil


    VOLUME /Users/Phil/Documents/myapp/myapp-docker/frontend/dist:usr/share/nginx/html

    EXPOSE 80



    docker-compose.yml

    version: '3'
    services:
    web:
    build: ./frontend
    ports:
    - "80:80"
    links:
    - node
    volumes:
    - "/Users/Phil/Documents/myapp/myapp-docker/frontend/dist:/usr/share/nginx/html"
    node:
    build: ./backend
    ports:
    - "3000:3000"



    console output:

    Building node
    Gracefully stopping... (press Ctrl+C again to force)
    Stopping myapp-docker_web_1 ... done

    C:\Users\Phil\Documents\myapp\myapp-docker>docker-compose up --build
    Building node
    Step 1/8 : FROM node
    ---> 2f1ff44a8bb5
    Step 2/8 : MAINTAINER Phil
    ---> Using cache
    ---> 78d7fb0bb77a
    Step 3/8 : WORKDIR /src
    ---> Using cache
    ---> 70e753257f23
    Step 4/8 : COPY . /src
    ---> Using cache
    ---> 2903a77a03ef
    Step 5/8 : RUN npm install
    ---> Using cache
    ---> 582d4f3b0a7b
    Step 6/8 : RUN npm install -g nodemon
    ---> Using cache
    ---> 1c9d67ce2743
    Step 7/8 : EXPOSE 3000
    ---> Using cache
    ---> 0d77a648b020
    Step 8/8 : CMD ["npm", "start"]
    ---> Using cache
    ---> 9adfbe7156f2
    Successfully built 9adfbe7156f2
    Successfully tagged myapp-docker_node:latest
    Building web
    Step 1/4 : FROM nginx
    ---> 2073e0bcb60e
    Step 2/4 : MAINTAINER Phil
    ---> Using cache
    ---> 1fba608ad1fa
    Step 3/4 : VOLUME /Users/Phil/Documents/myapp/myapp-docker/frontend/dist:usr/share/nginx/html
    ---> Running in 122358e91315
    Removing intermediate container 122358e91315
    ---> 2a54fcb0a4e6
    Step 4/4 : EXPOSE 80
    ---> Running in 95117506887d
    Removing intermediate container 95117506887d
    ---> 36a7c7bac5b8
    Successfully built 36a7c7bac5b8
    Successfully tagged myapp-docker_web:latest
    Recreating myapp-docker_node_1 ... done
    Recreating myapp-docker_web_1 ... done
    Attaching to myapp-docker_node_1, myapp-docker_web_1
    node_1 |
    node_1 | > backend@1.0.0 start /src
    node_1 | > node ./package.json
    node_1 |
    myapp-docker_node_1 exited with code 0
    web_1 | 2020/02/06 20:09:02 [error] 6#6: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.18.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1",
    host: "localhost"
    web_1 | 172.18.0.1 - - [06/Feb/2020:20:09:02 +0000] "GET /favicon.ico HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" "-"
    Gracefully stopping... (press Ctrl+C again to force)
    Stopping myapp-docker_web_1 ... done



    backend package.json

    {
    "name": "backend",
    "version": "1.0.0",
    "description": "",
    "main": "app.js",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node ./package.json"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
    "aws-sdk": "^2.612.0",
    "bcrypt": "^3.0.8",
    "body-parser": "^1.19.0",
    "create-hash": "^1.2.0",
    "crypto": "^1.0.1",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^5.8.11",
    "mongoose-unique-validator": "^2.0.3",
    "multer": "^1.4.2",
    "multer-s3": "^2.9.0"
    }
    }


    Here's my directory layout in case that's relevant

    [​IMG]

    Continue reading...

Compartilhe esta Página