Not able to connect to vue app in docker container (Vue+Flask+Docker)

Viewed 16

I am trying to set up a skeleton project for a web app. Since I have no experience using docker I followed this tutorial for a Flask+Vue+Docker setup:
https://www.section.io/engineering-education/how-to-build-a-vue-app-with-flask-sqlite-backend-using-docker/

The backend and frontend on their own run correct, now I wanted to dockerize the parts as described with docker-compose and separate containers for back- and frontend. Now when I try to connect to localhost://8080 I get this:
"This page isnt working, localhost did not send any data"

This is my frontend dockerfile:

#Base image
FROM node:lts-alpine

#Install serve package
RUN npm i -g serve

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json
COPY package*.json ./

# install project dependencies
RUN npm install

# Copy the project files
COPY . .

# Build the project
RUN npm run build

# Expose a port
EXPOSE 5000

# Executables
CMD [ "serve", "-s", "dist"]

and this is the docker-compose.yml

version: '3.8'

services:
    backend:
        build: ./backend
        ports: 
            - 5000:5000

    frontend:
        build: ./frontend
        ports: 
            - 8080:5000

In the Docker-Desktop GUI for the frontend container I get the log message "Accepting connections at http://localhost:3000" but when I open it in browser it connects me to the 8080 port.

During research I found that many people say I have to make the app serve on 0.0.0.0 to work from a docker container, but I don't know how to configure that. I tried adding

  devServer: {
    public: '0.0.0.0:8080'
  }

to my vue.config.js which did not change anything. Others suggested to change the docker run command to incorporate the host change, but I don't use that but use docker-compose up to start the app.

Sorry for my big confusion, I hope someone can help me out here. I really hope it's something simple I am overlooking.

Thanks to everyone trying to help in advance!

0 Answers
Related