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

Lets bring up a Website in a container
- HTML Refer Here download link
- steps
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
- apache:
- Create a file called as
Dockerfile - Now add the following
FROM nginx:1.27
COPY fashion/ /usr/share/nginx/html/fashion/

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

* Now lets view the images

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


* 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
- This instruction is used to select base image. official docs
FROM nginx
FROM nginx:1.27
- Platforms
- docker image building by default chooses the platform of host
- docker has given an additional command called
buildxto support cross platforms and multiplatforms - Best Practices:
- Always use a image with tag in FROM
