Upload
igor-gentil
View
129
Download
0
Tags:
Embed Size (px)
Citation preview
FROM ubuntu/trusty64
RUN apt-get update -y
RUN apt-get install -y nginx wget
COPY conf/nginx/* /etc/nginx/conf.d/
CMD [ “nginx” ]
EXPOSE 80
EXPOSE 443
FROM ubuntu/trusty64
RUN apt-get update -y
RUN apt-get install -y nginx wget
COPY conf/nginx/* /etc/nginx/conf.d/
CMD [ “nginx” ]
EXPOSE 80
EXPOSE 443
Base Image (downloaded from Docker Hub)
FROM ubuntu/trusty64
RUN apt-get update -y
RUN apt-get install -y nginx wget
COPY conf/nginx/* /etc/nginx/conf.d/
CMD [ “nginx” ]
EXPOSE 80
EXPOSE 443
Base Image (downloaded from Docker Hub)
Runs command. Generates new image
FROM ubuntu/trusty64
RUN apt-get update -y
RUN apt-get install -y nginx wget
COPY conf/nginx/* /etc/nginx/conf.d/
CMD [ “nginx” ]
EXPOSE 80
EXPOSE 443
Base Image (downloaded from Docker Hub)
Runs command. Generates new image
Runs command.
Generates new
image
FROM ubuntu/trusty64
RUN apt-get update -y
RUN apt-get install -y nginx wget
COPY conf/nginx/* /etc/nginx/conf.d/
CMD [ “nginx” ]
EXPOSE 80
EXPOSE 443
Base Image (downloaded from Docker Hub)
Runs command. Generates new image
Runs command.
Generates new
image
Copy all files from conf/nginx/
(relative to local directory) to the
container. Generates new image.
FROM ubuntu/trusty64
RUN apt-get update -y
RUN apt-get install -y nginx wget
COPY conf/nginx/* /etc/nginx/conf.d/
CMD [ “nginx” ]
EXPOSE 80
EXPOSE 443
Base Image (downloaded from Docker Hub)
Runs command. Generates new image
Runs command.
Generates new
image
Copy all files from conf/nginx/
(relative to local directory) to the
container. Generates new image.Sets default startup
command for the
container
FROM ubuntu/trusty64
RUN apt-get update -y
RUN apt-get install -y nginx wget
COPY conf/nginx/* /etc/nginx/conf.d/
CMD [ “nginx” ]
EXPOSE 80
EXPOSE 443
Base Image (downloaded from Docker Hub)
Runs command. Generates new image
Runs command.
Generates new
image
Copy all files from conf/nginx/
(relative to local directory) to the
container. Generates new image.Sets default startup
command for the
container
Configure ports 80 and 443 on
the container as “exposed” i.e.
NATed on the host OS.
Each step is a new image, built on top of
the one before.
If a step fails, the process is aborted and
can continue from the last valid image
once it’s corrected.
Since each component sits on a different
container, it’s safe to assume they need
to communicate, right?
So, how to do that?
Using Docker Compose!
Compose - previously known as Fig - is a tool
to coordinate multiple containers.
Simply define your containers in Dockerfiles
and the whole “environment” in docker-
compose.yaml
docker-compose.yaml:app:
build: .
links:
- redis
- elasticsearch
ports:
- “5000”:”5000”
redis:
image: redis
elasticsearch:
image: elasticsearch
Dockerfile:FROM python:2.7
WORKDIR /code
ADD . /code
RUN pip install -r requirements.txt
CMD python app.py
Example: Python web application with Redis
and ElasticSearch: