- Clone this repository
git clone https://github.com/bossan/docker-workshop - Go to the folder docker-workshop/examples/docker_compose.
Look at the docker-compose.yml file.
It contains the following information:
The version of the docker-compose file format we want to use. There are different versions so it is wise to specify which version you want to use in case there is an update.
The services (containers) we want to run. In this case it is:
- mongodb: the database using an existing image
- web: our web app that we created with our own Dockerfile
Volumes are a place to store data. We use it to store the data from our database. This way we can keep the data even if the container with the database is deleted or upgraded.
Run the following command to start the services:
docker compose up -dcomposebecause we want to use a docker-compose fileupto start the services-dto run it in 'detached' mode (runs in the background)
Run the following command to see which containers are currently running:
docker psGo to http://localhost:3000 to use the app. You can use the Swagger UI to interact with the API.
Using play-with-docker? Instead of opening localhost:3000 you should click on the "OPEN PORT" button and fill in
3000. This should open a new page with the application.
You can stop and REMOVE all containers with:
docker compose downOr you can just stop them (without removing) using:
docker compose stop