5. What is container?
History ->
- Containers have been there for a long time, maybe from the beginning of existence.
Container can be a pocket, bag, plastic or a large full metal container used in international
transportations.
- Containers are out there because:
- They are standard for almost everything.
- Can isolate things inside and protect them
- Are easy to transport
- Easy to manage
- Cost efficient
#FANDOGH2018
8. What is a docker container?
A docker container is a standard unit of
software that packages up code and all its
dependencies so the application runs
quickly and reliably from one computing
environment to another.
#FANDOGH2018
16. How to write Dockerfile?
- ADD
- COPY
- ENV
- EXPOSE
- FROM
- LABEL
- STOPSIGNAL
- USER
- VOLUME
- WORKDIR
#FANDOGH2018
17. How to write Dockerfile?
FROM nginx:alpine
#FANDOGH2018
18. How to write Dockerfile?
FROM nginx:alpine
The FROM instruction
initializes a new build
stage and sets the Base
Image for subsequent
instructions.
FROM
#FANDOGH2018
19. How to write Dockerfile?
FROM nginx:alpine
FROM can appear
multiple times within a
single Dockerfile to
create multiple images or
use one build stage as a
dependency for another
FROM
#FANDOGH2018
20. How to write Dockerfile?
FROM nginx:alpine
COPY index.html /usr/share/nginx/html
COPY has two forms:
COPY
#FANDOGH2018
23. How to write Dockerfile?
FROM nginx:alpine
COPY index.html /usr/share/nginx/html
The COPY instruction
copies new files or
directories from <src>
and adds them to the
filesystem of the
container at the path
<dest>.
COPY
#FANDOGH2018
24. How to write Dockerfile?
FROM nginx:alpine
COPY index.html /usr/share/nginx/html
1- cd to project root dir
2- Docker build -t hello_nginx:1.0 .
3- Docker run -d --name test_container hello_nginx:1.0
#FANDOGH2018
25. How to write Dockerfile?
FROM python:3
WORKDIR /code
The WORKDIR instruction
sets the working directory for
any RUN, CMD,
ENTRYPOINT, COPY and
ADD instructions that follow it
in the Dockerfile.
WORKDIR
#FANDOGH2018
26. How to write Dockerfile?
FROM python:3
WORKDIR /code
If the WORKDIR doesn’t
exist, it will be created even if
it’s not used in any
subsequent Dockerfile
instruction.
WORKDIR
#FANDOGH2018
27. How to write Dockerfile?
FROM python:3
WORKDIR /code
RUN pip install click
RUN has 2 forms
RUN
#FANDOGH2018
28. A
RUN <command> (shell form, the command is run in a shell, which by
default is /bin/sh -c on Linux or cmd /S /C on Windows)
#FANDOGH2018
30. How to write Dockerfile?
FROM python:3
WORKDIR /code
RUN pip install click
The RUN instruction will
execute any commands in a
new layer on top of the
current image and commit
the results. The resulting
committed image will be
used for the next step in the
Dockerfile.
RUN
#FANDOGH2018
31. How to write Dockerfile?
FROM python:3
WORKDIR /code
RUN pip install click
COPY . /code/
COPY has to forms
COPY
#FANDOGH2018
34. How to write Dockerfile?
FROM python:3
WORKDIR /code
RUN pip install click
COPY . /code/
The COPY instruction copies
new files or directories from
<src> and adds them to the
filesystem of the container at
the path <dest>.
COPY
#FANDOGH2018
35. How to write Dockerfile?
FROM python:3
WORKDIR /code
RUN pip install click
COPY . /code/
CMD ["python", "logger.py"] CMD has 3 forms
CMD
#FANDOGH2018
39. How to write Dockerfile?
FROM python:3
WORKDIR /code
RUN pip install click
COPY . /code/
CMD ["python", "logger.py"]
There can only be one CMD
instruction in a Dockerfile. If
you list more than one CMD
then only the last CMD will
take effect.
CMD
#FANDOGH2018
40. How to write Dockerfile?
FROM python:3
WORKDIR /code
RUN pip install click
COPY . /code/
CMD ["python", "logger.py"]
The main purpose of a CMD
is to provide defaults for an
executing container.
CMD
#FANDOGH2018
52. Fandogh Overview: Daily workflow
Docker Registry
Team
Version Control Server
Ci/Cd Automation Server
Building
1
Fandogh Service
2
Push
#FANDOGH2018
53. Fandogh Overview: What happens next
Docker Registry
S18
LB
S17
S19
S20
S21
You
Fandogh Service
Deploy command
1
2
3
4
#FANDOGH2018
57. Fandogh Features
● Flexible Docker Registry Interface
○ Internal Docker Registry
○ Docker-hub
○ Your Own Private Docker Registry
#FANDOGH2018
58. Fandogh Features
● Flexible docker registry interface
● Rich Runtime Environment
○ Internal Network and DNS for your services
○ Shared Persistent Storage
○ Dedicated Block-storage (coming soon)
#FANDOGH2018
59. Fandogh Features
● Flexible docker registry interface
● Rich Runtime Environment
● Managed Services
○ One-click deployment
○ MySQL + PHPMyAdmin
○ PostgreSQL + Adminer
○ And many more (Coming Soon)
#FANDOGH2018
60. Fandogh Features
● Flexible docker registry interface
● Rich Runtime Environment
● Managed Services
● Flexible Domain management and TLS Certificate Facilities
○ Free Fandogh Domain
○ Easily use your own domain for your services
○ Painless and Free Let’s Encrypt TLS Certificate
○ Automatic Renewal for Certificates
○ Use your Own Certificate (Coming Soon)
#FANDOGH2018
61. Fandogh Features
● Flexible docker registry interface
● Rich Runtime Environment
● Managed Services
● Flexible Domain management and TLS Certificate Facilities
● Horizontal Scaling, Painless Upgrades
○ Powerful Replication Mechanism
○ Load Balancing
○ Auto-Scaling (Coming Soon)
○ Offering high SLA with many reliable servers
○ Smart Health-check for rolling-updates
#FANDOGH2018
65. Decision
● Being Cloud-Native (or easy to become)
○ How is your design?Stateless or Stateful services?
○ Dockerization Cost
#FANDOGH2018
66. Decision
● Being Cloud-Native (or easy to become)
○ How is your design?Stateless or Stateful services?
○ Dockerization Cost
● Load and Cost relationship
○ How does your services loads affect your costs?
○ Do you predict high load in near future?
○ Do you predict the need for flexible scalability in near future?
#FANDOGH2018
67. Decision
● Being Cloud-Native (or easy to become)
○ How is your design? Stateless or Stateful services?
○ Dockerizing Cost
● Load and Cost relationship
○ How does your services loads affect your costs?
○ Do you predict high load in near future?
○ Do you predict the need for flexible scalability in near future?
● Geolocation dependency
○ Do you have strict criteria on physical location of servers?
(except enterprise plans)
#FANDOGH2018
73. Fandogh docker registry
Image management has two steps
● Creating Image for your codebase (Only once)
● Releasing new version for your codebase (for every version)
#FANDOGH2018
84. Where to find the project
git clone https://github.com/fandoghpaas/fandogh-workshop.git
#FANDOGH2018
85. How to deploy on
fandogh
The project manifests are located at /manifests directory.
Every service has a specific fandogh manifest that introduces
how the service should behave on fandogh.
#FANDOGH2018
92. Result manifest
fandogh service apply -d -f manifests/postgres-manifest.yml
fandogh service apply -d -f manifests/redis-manifest.yml
#FANDOGH2018
93. Result manifest
fandogh service apply -d -f manifests/postgres-manifest.yml
fandogh service apply -d -f manifests/redis-manifest.yml
fandogh service apply -d -f manifests/result-manifest.yml -p VERSION=?
Hint:
Find version in docker hub
#FANDOGH2018
94. Result manifest
fandogh service apply -d -f manifests/postgres-manifest.yml
fandogh service apply -d -f manifests/redis-manifest.yml
fandogh service apply -d -f manifests/result-manifest.yml -p VERSION=?
fandogh service apply -d -f manifests/vote-manifest.yml -p VERSION=?
#FANDOGH2018
95. Result manifest
fandogh service apply -d -f manifests/postgres-manifest.yml
fandogh service apply -d -f manifests/redis-manifest.yml
fandogh service apply -d -f manifests/result-manifest.yml -p VERSION=?
fandogh service apply -d -f manifests/vote-manifest.yml -p VERSION=?
fandogh service apply -d -f manifests/worker-manifest.yml -p VERSION=?
#FANDOGH2018
Editor's Notes
Docker is a computer program that performs operating-system-level virtualization, also known as "containerization". It was first released in 2013 and is developed by Docker, Inc.
https://www.docker.com/resources/what-container
https://www.docker.com/resources/what-container
https://docs.docker.com/v17.09/engine/userguide/storagedriver/imagesandcontainers/#images-and-layers
Think of it as magic beans.
At first they are just some small beans that can do nothing for you, but after putting them in the ground, they will become some fantastic and beautiful trees that can do many different things.Here Bean is Image, putting in the ground is deploying and Trees are containers that are ready to use and the ground is the platform.