DOCKERFILE (on top of docker image, there is an instruction layer)
A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.
vi Dockerfile (no extensions)
FROM ubuntu #downloading base
ARG DEBIAN_FRONTEND=noninteractive
#noninteractive for automation so it does not ask geographical bla bla bla..
RUN apt-get update
RUN apt-get update
#run is adding instruction on the instruction layer
RUN apt-get -y install apache2
ADD . /var/www/html
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 apachectl -D FOREGROUND
#entrypoint whenever docker image is used in a container, some commands need to be executed automatically
ENV name DEVOPS
ENV name DEVOPS
when doing this, docker will create an intermediate container to try each steps. after each steps, it will destroy the intermediate container and go to next step, then create an intermediate container again.
run the build image in a container:
docker container run --name webserver -dit -p 80:80 prod/webimg
from here you can do the following:
A) check if FROM ubuntu is confirmed:
go into the container:
docker exec -it webserver bash
then run this command:
uname -a
(this will confirm the ubuntu)
B) check if RUN is confimed:
in container, type:
service apache2 status
C) check if ADD . is confirmed:
in container, type:
ls /var/www/html/
D) check if ENV name DEVOPS is confimed:
in container, type:
env
in container, type:
ls /var/www/html/
D) check if ENV name DEVOPS is confimed:
in container, type:
env
No comments:
Post a Comment