Skip to content
Advertisement

How to dockerize a vuejs (frontend) app together with a (backend) flask api inside the same container?

I can successfully create and run backend flask api and the frontend vue app inside individual containers with the following codes:

JavaScript
JavaScript

But when I try combining them inside a single container, only the vue app is running on localhost:8080 but it cannot access the flask api output which I thought would be running locally inside the container on port 5000

JavaScript

Wondering if there is a way to run the flask api inside the container without spinning a separate container?

Advertisement

Answer

In a Dockerfile, the second CMD command will overwrite the previous one. Check this post to get more information on the topic.

In this case, a better approach would be to have two separate Dockerfiles (one for the backend and one for the frontend) and use Docker Compose to launch them simultaneously.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement