Commit 96d31305 authored by Paddy's avatar Paddy 🐧

Added some more slides

parent d7449918
Pipeline #587 passed with stage
in 2 minutes and 3 seconds
......@@ -3,7 +3,8 @@
- Using Docker to manage containers
- Where containers come from
- Our first container
- Manage multiple containers as a single service
- Manage multiple containers with a single command
- Some fancy stuff
- Extras
---
......@@ -300,26 +301,27 @@ Docker-compose will read a file in which we have all the definition of our conta
----
## Manage multiple containers: An example
## Manage multiple containers: An example from yesterday
```yaml
version: '3.3'
# List of the services
services:
db:
image: mysql:5.7
db:
image: mysql:5.7 # here we specify which image we want to user, same as docker run mysql:5.7
volumes:
- db_data:/var/lib/mysql
- db_data:/var/lib/mysql # here we attach the volume, same as docker run -v db_data:/var/lib/mysql
restart: always
environment:
environment: # here we pass environment variables, same as docker run -e [VARS]
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
depends_on: # here we specify that this container must run only after the db container
- db
image: wordpress:latest
ports:
......@@ -338,6 +340,110 @@ volumes:
# Demo!
---
# Some fancy stuff
----
## Some fancy stuffs
Ok, nice, but what if:
- We want to export or import a container?
- We want to make some kind of restriction on the container?
- We want reboot my server?
----
## Some fancy stuffs
### Export/import containers
Sometimes arise the problem to export and import containers (e.g. move containers between computers but not connection)
----
## Some fancy stuffs
### Export/import containers
To do so we can:
```bash
# Export to an archive
$ docker export httpd | gzip > httpd.gzip
# Import in an archive
$ zcat httpd | docker import - httpd
```
----
## Some fancy stuffs
### Restrict my containers
How can I restrict the usage of some resources (e.g. CPU, I/O, ecc) used by my containers?
----
## Some fancy stuffs
### Restrict my containers
```bash
# Limit the CPU usage for half of a CPU
$ docker run --cpus=0.5 httpd
# Limit memory usage
$ docker run --memory=1G httpd
# Give access to Nvidia GPUs (you have to install some package before doing this)
$ docker run -it --rm --gpus all ubuntu nvidia-smi
```
----
## Some fancy stuffs
### Survival between reboots
Ok, now we have all our containers with all our options aaaaand....
We reboot our server.
Will my services be up?
----
## Some fancy stuffs
### Survival between reboots
Nope. I have to specify to the docker daemon that they have to be up:
----
## Some fancy stuffs
### Survival between reboots
```bash
# Restart always the containers, on failure or on reboot
$ docker run -p 8080:80 --restart=always httpd
```
----
## Some fancy stuffs
### Survival between reboots
```yaml
# Same, but in a docker-compose.yml
version: '3'
services:
httpd:
image: httpd
container_name: httpd
restart: always
ports:
- "8080:80"
```
---
# Demo!
---
......@@ -346,6 +452,8 @@ volumes:
- [Docker](https://www.docker.com/)
- [Dockerfile Reference](https://docs.docker.com/engine/reference/builder/)
- [What even is a container](https://jvns.ca/blog/2016/10/10/what-even-is-a-container/)
- [Usage of NVIDIA GPUs](https://docs.docker.com/config/containers/resource_constraints/#access-an-nvidia-gpu)
- [Source of croc example](https://github.com/jldeen/croc-hunter/tree/dockerfile-demo)
---
......@@ -353,11 +461,44 @@ volumes:
---
## Do I really need containers?
No? Yes? It depends...
----
### Do I really need containers?
When I **need** a container?
- When I want to develop an application that will be managed by a Container Orchestrator
----
### Do I really need containers?
When is it **convenient** to use containers?
- When I have too much dependencies (Node I'm looking at you)
- When I have an application that is already dockerized
- When I want to have some isolation between my dockerized app and my host system
----
### Do I really need containers?
When do the containers not solve my problems?
- **Security** Containers don't protect you from bugs in the kernel (shared between host and container) or in the application
- **Privacy** Unless your data is _not inside a container_, your data is safe as long as the application is secure
---
### Manage container on production scale
Ok, this is really nice, now we can manage containers in a single host.
What if we want to manage containers in multiple hosts, in a production grade enviroment?
What if we want to manage containers in multiple hosts or in a production grade enviroment?
----
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment