Running it all together

So, we have our web_server, application_server, and database containers all figured out. Let's verify that you have all the files matching these before moving on:

$ tree .
.
├── application_server
│ ├── Dockerfile
│ ├── index.js
│ ├── package.json
│ └── views
│ └── index.pug
├── database
│ └── Dockerfile
└── web_server
├── Dockerfile
└── nginx_main_site.conf

4 directories, 7 files

The next step for us is to build all the containers:

 $ # Build the app server image
$ cd application_server
$ docker build -t application_server .
Sending build context to Docker daemon 34.3kB
Step 1/10 : FROM node:8
<snip>
Successfully built f04778cb3778
Successfully tagged application_server:latest

$ # Build the database image
$ cd ../database
$ docker build -t database .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM mongo:3
<snip>
Successfully built 7c0f9399a152
Successfully tagged database:latest

$ # Build the web server image
$ cd ../web_server
$ docker build -t web_server .
Sending build context to Docker daemon 3.584kB
Step 1/8 : FROM nginx:latest
<snip>
Successfully built 738c17ddeca8
Successfully tagged web_server:latest
This sequential building is great for showing what needs to be done in each step, but always think about automation and how manual processes can be improved. In this particular case, this whole block of statements and execution could have also been done from the parent directory with this single line: for dir in *; do cd $dir; docker build -t $dir .; cd ..; done
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.68.3