Running application.
How to modify the application to run on the cloud?
Each application has its dependencies on lower layers:
Changing HW, LIB or OS requires changing the application.
Example for layers:
A Dockerfile is instructions on how to build an image.
FROM dockerfile/ubuntu
RUN \
add-apt-repository -y ppa:nginx/stable && \
apt-get update && \
apt-get install -y nginx && \
rm -rf /var/lib/apt/lists/* && \
echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \
chown -R www-data:www-data /var/lib/nginx
WORKDIR /etc/nginx
CMD ["nginx"] # Define default command.
It has coded in it
docker build . -t myregistry.tuke.sk/mynginx:0.1
|-----------------|-------|---|
registry image tag
Dockerhub central repository or custom registry
docker run nginx
on the background
docker run -it --rm nginx
with console
+----------+
| Registry |
+----------+
| Pull
v
+--------+
| Image |
+--------+
| Run
v
+-----------+
| Container |
+-----------+
It sees virtual devices
The container sees "its" network.
docker run -it --rm -p 8000:80 nginx
^ ^
| |
host container
docker run -p 80:80 -v /var/www:/var/www nginx
Mapping between real and virtual directory.
+------------------+
| Operating system |
+------------------+
| build
+-------------+
| Application |-----------+----------------+
+-------------+ | |
| OverlayFS | Config | Volume
+-----------------+ +---------------+ +--------------------+
| Temporary files | | Configuration | | Application status |
+-----------------+ +---------------+ +--------------------+
a part of the file system that changes and that is essential even after a restart, e.g. database
We can mount an existing local folder into a new container
Connecting the current directory:
docker run -it --rm -v .:/home/user bash
docker volume create myvolume
docker run -it --rm -v myvolume:/myvolume bash