I am doing my first steps with docker compose and made a docker-compose.yml file which contains:
version: "3.8"
services:
web:
build: ./frontend
ports:
- "3000:3000"
api:
build: ./backend
ports:
- "3001:3001"
environment:
DB_URL: mongodb://db/slip
db:
image: mongo:4.0-xenial
ports:
- "27017:27017"
volumes:
- slip:/data/db
volumes:
slip:
However after running $ docker-compose build
This is my result images in docker:
REPOSITORY TAG IMAGE ID CREATED SIZE
slip_api latest 445199e1e418 43 seconds ago 184MB
slip_web latest c1168ad560b8 About a minute ago 299MB
node 14.16.0-alpine3.13 50bfd284aa0d 10 months ago 117MB
I am not sure why I don't see the mongo:4.0-xenial image, and also not sure why I see the node:14.16.0-alpine3.13 which is a base (FROM) in docker file of the slip_api and slip_web and not an image by itself that I built.
Using Ubuntu 20.04.3 LTS
Thanks for the help!
CodePudding user response:
docker-compose build
does literally that: it builds images. In order for an image to be built, the base image needs to present. That is the reason, why you are seeing the node
image present.
You do not see the mongoDB image, because it is not built. Once you attempt to docker-compose up
it will pull the latest version of mongo:4.0-xenial