Task-Based on both Docker Sessions of the masterclass
artic;e on docker

Task-Based on both Docker Sessions of the masterclass

what is docker

Docker is an open-source platform for building, deploying, and managing containerized applications. Learn about containers, how they compare to VMs, and why Docker is so widely adopted and used. It enables developers to package applications into containers—standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment. Containers simplify the delivery of distributed applications and have become increasingly popular as organizations shift to cloud-native development and hybrid?multi-cloud?environments.

#TASK2.1:?The compose should deploy two services (web and DB), and each service should deploy a container as per details below:

For web service: --->> php:rc-apache

No alt text provided for this image

a. Container name must be php_web.

b. Use image php with any apache tag. Check here for more details?https://hub.docker.com/_/php?tab=tags.

c. Map php_web container's port 80 with host port 6000

d. Map php_web container's /var/www/html volume with host volume /var/www/html.

For DB service:

a. Container name must be mysql_web.

b. Use image mariadb with any tag (preferably latest). Check here for more details?https://hub.docker.com/_/mariadb?tab=tags.

c. Map mysql_web container's port 3306 with host port 3306

d. Map mysql_web container's /var/lib/mysql volume with host volume /var/lib/mysql.

e. Set MYSQL_DATABASE=database_web and use any custom user ( except root ) with some complex password for DB connections.

After running docker-compose up you can access the app with curl command curl <server-ip or hostname>:6000/ ____________

Solution:-

1) create a docker-compose file using vim, Edit the Docker-compose file, the first section to define web portion and the second section defines the databse

No alt text provided for this image
No alt text provided for this image

2) creating the inde.php and edit the file and add credentials for mysql

No alt text provided for this image
No alt text provided for this image

3) now create Dockerfile using vim, Edit that file put some specific keywords that dictate how to build a specific image.

No alt text provided for this image
No alt text provided for this image

4) install Docker compose for project

No alt text provided for this image

5) change the file mode(action)

No alt text provided for this image

6) need to build the container (Docker container)

No alt text provided for this image

7) use Docker-compose-up to aggregate the output of each container

No alt text provided for this image

8) Docker-compose up -d command for detached mode

No alt text provided for this image
No alt text provided for this image

#TASK2.2:?Dockerfile

1) Webserver

2) This is coming from Docker ---> Content

3) CentOS?

solution:-

1) create a new directory and get into that after that create an index.html file and create dockerfile which include the specific keyword that dictates how to build a specific image

No alt text provided for this image

#html file

No alt text provided for this image
No alt text provided for this image

2) now strat the docker service and create the docker image inside the Dockerfile

No alt text provided for this image

#set the webserver "docker run -dit -p 3000:80"

No alt text provided for this image

3) Go to the web browser and check localhost:3000

No alt text provided for this image

#Thankyou for seeing my article

要查看或添加评论,请登录

Saurabh Sinha的更多文章

  • TASK BASED ON LINUX SESSIONS

    TASK BASED ON LINUX SESSIONS

    1) Create a file via Touch and update that file and also verify the timestamp and output will be redirected to another…

    2 条评论
  • An article on the importance of optimization

    An article on the importance of optimization

    what is optimization? Maximizing or minimizing some function relative to some set, often representing a range of…

    6 条评论
  • An Article on GIT and GITHUB

    An Article on GIT and GITHUB

    1. What is the difference between pushing and pulling.

    4 条评论

社区洞察

其他会员也浏览了