Docker Notes
Docker Notes
We know that container does not have any public ip of its own….
So if the application is running inside the container how we can
access it then
Press ctrl p and ctrl q to come out of the container without stopping
the container
Go to your instance
Copy the public ip of the machine
# Docker files
It is text file which consist of set of instructions
And it automates the docker image creation
Case study:
Lets suppose you are working for Netflix ..and you are devops
engineer…there is an application you need to deploy for netflix…
Now problem which you are facing is that app requires more then
100 dependencies and alot of environment variables need to be
passed when the container was created. You went to Developer
and how to configure so many things inside the container ..
So developer said : let me a dockerfile…which will consist of app,
base image, dependencies , and everything required by the
application to run inside the container..after the developer shared
you that dockerfile you simply executed the dockerfile to create a
custom image…and from the custom image you created n number
of containers.
How to write the dockerfile ?????????????????
Dockerfile is made of key-component system
FROM -> For the base image the command need to be on the top
of the dockerfile
E.g
MAINTAINER akshat<[email protected]>
MAINTAINER akshatgupta
COPY -> COPY the files from local system (Docker virtual
machine/EC2) . For example: lets say there is a index.html file in
your machine …and when the container is getting created you want
to copy that file inside the container in this case you will use COPY
ADD -> Similar to copy…it can copy the file from your machine to
container but can also download the file from internet into your
container
E.g
ADD /home/ubuntu/index.html /var/www/html/index.html
EXPOSE -> It exposes the port of the container like port 80 if your
app is running over internet ….or port 8080 if you are creating
jenkins container ….or port 3306 for mysql…
If you dont put expose then also you will be able to do port
expose…but since the devops engineer they might not aware on
which port the developer has configured the application…if expose
is there it makes it easier devops engineer to deploy the application
Eg
ENV name=akshat