# version of docker compose
version: '3'

# We can setup multiple services in one go
services:
# provide the name of the service, can be anything
	node-app:
# everything below here are the same docker cli commands
	build: .
	port:
		- "3000:3000"
	volumes:
	# docker compose let you use relative path for volumes
		- ./:/app
	# this is a trick so node_modules dont get overridden
		- /app/node_modules
	environment:
	# we can provide envs either explcity or with env file
		- PORT=3000
		# env_file:
		# - fileName

execute by running docker-compose up . To tear down docker-compose down additionally provide -v flag to remove related volumes.

docker-compose also builds the image and will cache this step if it can.

note: if you update your Dockerfile, docker-compose is not smart enough to know to rebuild the image. use the --build flag to force a rebuild of the image

docker-basics