Day26 1
Day26 1
Day26 1
--------------------
This is a simple text file, which uses predefinied keywords for creating
customized docker images.
1) FROM -- used to specify the base image from which the docker file has to be
created.
3) CMD -- This is used to specify the initial command that should be executed
when the container starts.
4) ENTRYPOINT - used to specify the default process that should be executed when
container starts.
It can also be used for accepting arguments from the CMD instruction.
5) RUN -- Used for running linux commands within the container. It is generally
helpful for installing the software in the container.
6) USER -- used to specify the default user who should login into the
container.
7) WORKDIR --
Used to specify default working directory in the container
8) COPY -- Copying the files from the host machine to the container.
9) ADD -- Used for copying files from host to container, it can also be used
for downloading files from remote servers.
10) ENV -- used for specifying the environment variables that should be passed
to the container.
+++++++++++++++++++++
+++++++++++++++++++++++++++++++++
FROM nginx
MAINTAINER logiclabs
:wq
++++++++++++++++++++++++++++++++++++++++++++++
# vim dockerfile
FROM centos
MAINTAINER logiclabs
CMD ["date"]
:wq
++++++++++++++++++++++++++
:wq
++++++++++++++++++++++++++++++++++++++++++++++
In ubuntu container, I want to install git in it.
FROM ubuntu
MAINTAINER logiclabs
RUN apt-get update
RUN apt-get install -y git
:wq
Lets see the images list and space consumed by our image
# docker images
++++++++++++++++++++++++++++++++++
# mkdir docker
# mv dockerfile docker
# cd docker
# ls
docker# git init
docker# git status
docker# git add .
docker# vim dockerfile ( lets make some changes add another RUN command )
FROM ubuntu
MAINTAINER logiclabs
:wq
+++++++++++++++++++++++++++++++++++
Cache busting
------------------
Whenever an image is build from a dockerfile, docker reads its memory and checks
which instructions were already executed.
These steps will not be reexecuted.
It will execute only the latest instructions. This is a time saving mechanism
provided by docker.
But, the disadvantage is, we can end up installing software packages from a
repository which is updated long time back.
Ex:
# cd docker
# vim dockerfile
FROM ubuntu
MAINTAINER logiclabs
:wq
Disadvantage : Lets say, you are running after 4 months, We are installing tree
from apt which is updated long time back. )
# vim dockerfile
FROM ubuntu
MAINTAINER logiclabs
:wq