Jan Tuđan
Jan Tuđan

Reputation: 171

How to put an existing container in docker-compose?

I already have a vue application containerized and running, but how do I put it in docker compose?

Dockerfile:

FROM node:14

WORKDIR /app

RUN  npm install @babel/core @babel/node @babel/preset-env nodemon express axios cors mongodb

COPY . .

EXPOSE 4200

CMD ["npm", "run", "serve"]

So when I try to put port "4200" it says that I have already the same port running, so how do I put that container inside whole app which will store multiple containers?

This is my docker-compose try:

version: '3.8'
services: 
  posts:
    build: ./posts
    ports: 
      - "4200:4200"

So this is the visualisation of something that I want to do:

enter image description here

Upvotes: 2

Views: 1181

Answers (1)

Makariy
Makariy

Reputation: 795

Change host port in compose

For example:

ports: 

  - "4201:4200"

Upvotes: 2

Related Questions