DevOps Classroom notes 29/Jan/2025

Containerizing applications

  • Generally we run serverside components in the containers such as web servers, databases, webstores etc…
  • Monolith vs Microservices
    Preview

Lets bring up a Website in a container

mkdir website
cd website
wget https://www.free-css.com/assets/files/free-css-templates/download/page296/little-fashion.zip
unzip little-fashion.zip
mv 2127_little_fashion/ fashion/
# move this folder to html location in webserver 2127_little_fashion
# mv 2127_little_fashion /var/www/html/fashion/
  • Webservers:
    • apache: /usr/local/apache2/htdocs/
    • nginx: default directory /usr/share/nginx/html
  • Create a file called as Dockerfile
  • Now add the following
FROM nginx:1.27
COPY fashion/ /usr/share/nginx/html/fashion/

Preview

  • Now to build the docker image lets use docker build command
docker image build -t fashion:1.0 .

Preview
* Now lets view the images
Preview

  • Now lets build the container with this image
docker container run -d --name web1 -P fashion:1.0

Preview
Preview
* Note: use this instruction docker container run -d --name web2 -p 80:80 fashion:1.0

Dockerfile

  • Dockerfile contains instructions to build the image
  • basic syntax
<INSTRUCTION 1> <arguments>
<INSTRUCTION 2> <arguments>
..
<INSTRUCTION n> <arguments>

Necessary instructions

FROM

FROM nginx

FROM nginx:1.27
  • Platforms
  • docker image building by default chooses the platform of host
  • docker has given an additional command called buildx to support cross platforms and multiplatforms
  • Best Practices:
    • Always use a image with tag in FROM

ADD COPY

  • ADD
  • COPY
  • ADD instruction can copy the file or folder into docker image from host or remote sources (https)
  • COPY instruction can copy file or folder into docker image from host
  • Exercise: Try building a docker image for carvilla with the following base image

    • nginx
    • httpd

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube