(Created page with " Category:Docker") |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Docker Compose == | |||
Dockerfile provides a declaritive way of building images<br> | |||
==== Write a Dockerfile ==== | |||
<pre> | |||
version: '2' | |||
services: | |||
db: | |||
image: mongo:latest | |||
container_name: db | |||
networks: | |||
- appnet | |||
web: | |||
image: nginx:latest | |||
networks: | |||
- appnet | |||
ports: | |||
- "3000" | |||
networks: | |||
appnet: | |||
driver: bridge | |||
</pre> <br> | |||
''Specifically in this example there is no port defined for the localhost in order to be able to scale the web application''<br> | |||
== Docker Compose == | |||
Docker Compose groups and launches multiple containers together <br> | |||
<code> | |||
docker-compose -d up | |||
</code> <br> | |||
==== Check logs ==== | |||
<code> | |||
docker-logs db | |||
</code> <br> | |||
<code> | |||
docker-logs web | |||
</code> <br> | |||
All<br> | |||
<code> | |||
docker compose logs web | |||
</code> <br> | |||
[[Category:Docker]] | [[Category:Docker]] |
Latest revision as of 23:26, 24 April 2020
Docker Compose
Dockerfile provides a declaritive way of building images
Write a Dockerfile
version: '2' services: db: image: mongo:latest container_name: db networks: - appnet web: image: nginx:latest networks: - appnet ports: - "3000" networks: appnet: driver: bridge
Specifically in this example there is no port defined for the localhost in order to be able to scale the web application
Docker Compose
Docker Compose groups and launches multiple containers together
docker-compose -d up
Check logs
docker-logs db
docker-logs web
All
docker compose logs web