Followers

Docker Volume Assignment

  1. Create a docker apache image using Dockerfile.  2. Create a deploy-vol docker volume.  3. Run a container using docker apacheimg with p...

 1. Create a docker apache image using Dockerfile.

 2. Create a deploy-vol docker volume.

 3. Run a container using docker apacheimg with port forwarding 80:80 and map /var/www/html folder to deploy-vol.

4. Check default apache page is accessible on the browser.

5. Copy/Create a test.html file under /var/lib/docker/volumes/deploy-vol/_data

6. Check on the browser that you are able to access this webpage (test.html)

7. Go inside the container and create a file newtest.html under /var/www/html and verify that you are able to access it with the browser.

COMMENTS

BLOGGER: 9
  1. This comment has been removed by the author.

    ReplyDelete
  2. 1. vi Dockerfile

    1.2 in Dockerfile:
    FROM ubuntu
    #from is getting the base image

    ARG DEBIAN_FRONTEND=noninteractive
    #noninteractive for automation so it does not ask questions such as geographical..

    RUN apt-get update
    #run is adding instruction on the instruction layer

    RUN apt-get -y install apache2

    ADD . /var/www/html
    #add is copy the file from host machine to docker image folder

    ENTRYPOINT apachectl -D FOREGROUND
    #entrypoint whenever docker image is used in a container, some commands need to be executed automatically

    ENV name DEVOPS
    #environment variable is used on the global level

    1.3 docker build . -t apacheimg

    2. docker volume create deploy-vol

    3. docker container run --name assignment1 -v deploy-vol:/var/www/html -dit -p 80:80 apacheimg

    4. curl localhost

    5. echo "h1 Welcome to test.html page! /h1" > /var/lib/docker/volumes/deploy-vol/_data/test.html

    6. curl localhost/test.html

    7. docker exec -it assignment1 bash

    7.2 in container:

    echo "h1 This is newtest page and NOT test page! /h1" > /var/www/html/newtest.html

    7.3 exit container:

    exit

    7.4 curl localhost/newtest.html

    ReplyDelete
  3. 1. Create a docker apache image using Dockerfile.
    -> vi Dockerfile
    FROM ubuntu
    ENTRYPOINT ["echo"]
    CMD ["Hello World"]FROM ubuntu
    ARG DEBIAN_FRONTEND=noninteractive
    RUN apt-get update
    RUN apt-get -y install apache2
    ADD . /var/www/html
    ENTRYPOINT apachectl -D FOREGROUND
    ENV name DEVOPS

    -> docker build . -t apacheimg

    2. Create a deploy-vol docker volume.
    ->  docker volume create deploy-vol

    3. Run a container using docker apacheimg with port forwarding 80:80 and map /var/www/html folder to deploy-vol.
    -> docker container run -dit —name c1 -v deploy-vol:/var/www/html -p 80:80 apacheimg

    4. Check default apache page is accessible on browser.
    On browser enter: localhost:80 , > Apache2 Ubuntu Default Page running

    5. Copy/Create a test.html file under /var/lib/docker/volumes/deploy-vol/_data
    -> echo “test text ABC” > /var/lib/docker/volumes/deploy-vol/_data/test.html

    6. Check on the browser that you are able to access this webpage (test.html)
    -> On browser enter: localhost/test.html , yes

    7. Go inside the container and create a file newtest.html under /var/www/html and verify that you are able to access it with the browser.
    -> docker exec -it c1 bash
    -> echo "Second test page" > /var/www/html/newtest.html
    -> On browser enter: localhost/newtest.html , yes

    ReplyDelete
  4. 1. mkdir dockasgn
    cd dockasgn
    vi Dockerfile
    FROM ubuntu
    ARG DEBIAN_FRONTEND=noninteractive
    RUN apt-get update
    RUN apt-get -y install apache2
    ADD . /var/www/html
    ENTRYPOINT apachectl -D FOREGROUND
    ENV name DEVOPS

    2. docker volume create deploy-vol

    3. docker container run -dit --name apacheimg -v deploy-vol:/var/www/html -p 80:80 ubuntu

    4. curl localhost:80

    5. echo “Test HTML” >> /var/lib/docker/volumes/deploy-vol/_data/test.html

    6. localhost/test.html

    7. docker exec -it apacheimg bash
    touch /var/www/html/newtest.html
    exit
    ls /var/lib/docker/volumes/demo-vol/_data

    ReplyDelete
  5. 1. vi Dockerfile

    FROM ubuntu

    ARG DEBIAN_FRONTEND=noninteractive

    RUN apt-get update

    RUN apt-get -y install apache2

    ADD . /var/www/html

    ENTRYPOINT apachectl -D FOREGROUND

    ENV name DEVOPS

    docker build . -t apacheimg

    2. docker volume create deploy-vol

    3. docker container run --name a1 -v deploy-vol:/var/www/html -dit -p 80:80 apacheimg

    4. Checked ok

    5. echo "h1> Hello World /h1>" > /var/lib/docker/volumes/deploy-vol/_data/test.html

    6. checked ok

    7. docker exec -it a1 bash
    cd /var/www/html
    echo "h1> Second test /h1>" >> newtest.html
    checked ok

    ReplyDelete
  6. Mikraj:

    1. Create a docker apache image using Dockerfile.
    vi Dockerfile
    FROM ubuntu
    #from is getting the base image
    ARG DEBIAN_FRONTEND=noninteractive
    #noninteractive for automation so it does not ask questions such as geographical..
    RUN apt-get update
    #run is adding instruction on the instruction layer
    RUN apt-get -y install apache2
    ADD . /var/www/html
    #add is copy the file from host machine to docker image folder
    ENTRYPOINT apachectl -D FOREGROUND
    #entrypoint whenever docker image is used in a container, some commands need to be executed automatically
    ENV name DEVOPS
    #environment variable is used on the global level
    docker build . -t apacheimg

    2. Create a deploy-vol docker volume.
    docker volume create deploy-vol

    3. Run a container using docker apacheimg with port forwarding 80:80 and map /var/www/html folder to deploy-vol.
    docker container run -it --name c1 -p 80:80 --mount source=deploy-vol,destination=/var/www/html -d apacheimg

    4. Check default apache page is accessible on the browser.
    curl localhost OR localhost:80 on browser

    5. Copy/Create a test.html file under /var/lib/docker/volumes/deploy-vol/_data
    vi test.html
    h1 hello this is practice /h1
    cp test.html /var/lib/docker/volumes/deploy-vol/_data

    6. Check on the browser that you are able to access this webpage (test.html)
    curl localhost/test.html OR localhost/test.html on browser

    7. Go inside the container and create a file newtest.html under /var/www/html and verify that you are able to access it with the browser.
    docker exec -it c1 bash
    cd /var/www/html
    touch newtest.html
    echo “h1 this is added, this new test /h1” >> newtest.html
    curl localhost/newtest.html OR localhost/newtest.html on browser

    ReplyDelete

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Docker Volume Assignment
Docker Volume Assignment
DevOpsWorld
https://www.devopsworld.co.in/2022/02/docker-volume-assignment.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/02/docker-volume-assignment.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content