Reputation: 28790
I have this simple Dockerfile:
FROM node:boron
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
I would like to use docker-compose so that I can simply say docker-compose up
or docker-compose down
.
I am struggling to find a simple docker-compose example of how I would use docker-compose
, all I can find are examples like this which cover more ground than I need.
How could I create a simple docker-compose file from the above?
Upvotes: 2
Views: 5591
Reputation: 1333
You write following in docker-compose.yml
file to run your docker container using compose:
version: '3'
services:
app:
build: .
ports:
- 8080:8080
Docker compose file is made of multiple services but in your case it is enough to define one service. build
option specifies from where to pick up the Dockerfile to build the image and ports
will allow port forwarding from the container to you host OS.
To start the service you can use:
docker-compose up
And to stop the service:
docker-compose down
You can find more documentation about the compose file here
Upvotes: 10