Docker compose
Docker uses Dockerfiles to specify what an image should look like. It uses something called "compose" files to allow you to specify multiple containers that can talk to each other.
Exercise
Answer
    Add a section to the "docker-compose.yml" file which specifies a Mongo DB image. Name it "mongo"
    Link that image with the "start" image
    Run the image
    Notice that both a "start" image and a "mongo" image are created
    Open the "docker-compose.yml" file in the "start" project
    Add a new section under "services" called "mongo"
1
version: '2.1'
2
3
services:
4
start:
5
image: start
6
build: .
7
environment:
8
NODE_ENV: production
9
ports:
10
- 3000:3000
11
12
mongo:
Copied!
    Specify the "mongo" image to be pulled down from Dockerhub
1
version: '2.1'
2
3
services:
4
start:
5
image: start
6
build: .
7
environment:
8
NODE_ENV: production
9
ports:
10
- 3000:3000
11
12
mongo:
13
image: 'mongo'
Copied!
    Add a line just below line 10 that links the "start" container with the "mongo" container
1
version: '2.1'
2
3
services:
4
start:
5
image: start
6
build: .
7
environment:
8
NODE_ENV: production
9
ports:
10
- 3000:3000
11
links:
12
- mongo
13
14
mongo:
15
image: 'mongo'
Copied!
    Open the Command Palette(Cmd/Ctrl + Shift + P)
    Select "Docker: Compose Up"
    Select the "start" project
    Select the "docker-compose.yml" file from the prompt
    Open the Docker Explorer view and notice that there are now two containers running
Last modified 2yr ago
Copy link