DockerTutorial
#DockerTutorial
Docker Container
Docker Tutorial For Beginners
#Devops
#Dockerbuild
Docker Install
...How to create container from our own image
...how to create docker file / Image out of docker file
...Create volumes and How to map with Host and containers.
Let's see these things...
1.Now To create container from image
docker run --name rangacontainer -it ubuntu //bin/bash
now im in container ranga.
2.Here we will create one empty file
touch /tmp/rangafile
3.see the differences between the main image (ubuntu) and Rangacontainer.
run this outside of container.
docker diff rangacontainer
it will show the what are the changes made to that container...
4.Now create image from container (be inside base machine)
docker commit rangacontainer
5.To give a name to our image.
see all the images what are in our docker...
docker images
docker tag imageid ranimage
i have changed the ubuntu image with ranimage and created new one.
6.To give image name while creating image.
docker commit rangacontainer imagename
7.create container from our image
docker run --name rangascontainer -it rangaimage //bin/bash
ohh i have the same container name...give new name...
Docker file:
------------
1.Create a file named dockerfile
vi dockerfile
FROM ubuntu
RUN echo "Hello world" here right arrow /tmp/testfile
Check it with these commands
docker build -t test . (it will build the new image with ubuntu named as
test)
docker ps -a (see all the containers list)
docker images (see all the images)
Create container from above image:
docker run --name testcontainer test //bin/bash
2.add instructions in dockerfile
vi dockerfile
FROM ubuntu
WORKDIR /tmp
RUN echo "Hi ranga" here right arrow /tmp/testfile
ENV myname ranga
COPY testfile1 /tmp (testfile1 must be in Current ec2 directory)
ADD test.tar.gz /tmp (test.tar.gz must be in Current ec2 directory)
we got all the files but tar.gz is missing...will see that....
it's not missing...When we run that dockerfile the compressed file will
uncompress that means ===We created test.tar.gz from test file
this test file will be visible there....
3.build dockerfile to create image
docker build -t test .
4.run image to create container
docker run -it --name testcontainer1234 test //bin/bash
testcontainer1234=== is your wish
test=== is the image file (from which image we are creating container)
Now will move to volume...
1.Edit the Dockerfile
vi dockerfile
FROM UBUNTU
VOLUME ["/data"]
Now run it with docker build -t myimg .
Run container docker run -it --name mycont1 myimg //bin/bash
it will take the image ubuntu and create a volume name data.
2.Now create onefile inside data volume
touch /data/myfile
3.Exit from that container.
Now will share this volume with another container
(Container to container).
4.docker run -it --name mycont2 --privileged=true --volumes-from mycont1 ubuntu //bin/bash
here i am creating another container and also sharing the mycont1 volume(data)...
see we got the myfile in mycont2...
5.Now will create another file in mycont2 will see in mycont1.
touch frommycont2.
if you goto mycont1 will see the frommycont2 file there...
Now will declare the volume by using command not from dockerfile...
6.docker run -it --name mycont3 -v /ranga ubuntu //bin/bash
here i am creating mycont3.
ranga is my volume
ubuntu is my image.
if we run that command will see ranga volume there...
7.Share volumes from host - container
docker run -it --name newcont -v /home/ec2-user:/raj --privileged=true ubuntu //bin/bash
here i have created new container named as newcont
volume is raj
and we shared the /home/ec2-user with raj volume...
what ever we have in our machine (/home/ec2-user) that will share with
raj volume...
will check one more time...
touch from rajvolume.see the ec2-user and raj volume are sharing....
that's it for volumes...
docker inspect newcont
it will give full details of the container
How to Create Dockerfile and Containers | How to Create and Share Volume | Docker Tutorial Part -2
#Docker Tutorial #Docker Run #Docker Install #Docker Container #Docker Build
#Docker Tutorial For Beginners
• Create Dockerfile and Containers and ...
Docker Installation | Create A Container - Docker Commands | Docker Tutorial for Beginners Part-1
#Docker Tutorial #Docker Run #Docker Install #Docker Container #Docker Build #Docker #Devops
#Docker Tutorial For Beginners
• Docker Compose | Docker Container - D...
That's it for this video...
Now subscribe for more videos like this...
Next video will be on docker export
after that will move to ansible....