0

when I've build Images from dockerfile it's working as usual.

dockerfile

FROM node:14.17.3
WORKDIR /usr/src/app
COPY ./ ./
RUN npm install
CMD [ "/bin/bash" ]

building from dockerfile

image building

port

output

 output in browser

but, when I've tried to build image from docker-compose file the ports isn't working

docker-compose file

version: "3.9" 
services: 
  backend:
    container_name: backend 
    build: .
    ports: 
      - "3000:3000"

docker-compose build

docker-compose build

docker-compose run docker-compose run

output output

porosh
  • 77
  • 1
  • 6
  • This question might be easier to read if you pasted the actual text output of the `docker build` and other commands. In general, avoid pasting screen shots of terminal windows or IDEs into Stack Overflow questions; the actual command and output as text are easier to read, search, and reproduce. – David Maze Jul 10 '21 at 13:38

1 Answers1

1

You need to run docker-compose up backend instead of docker-compose run backend.

See https://stackoverflow.com/a/33066676/413924 for more details.

DannyB
  • 12,810
  • 5
  • 55
  • 65