Source from Zeal Vora,KPLABS Course(Premium Instructor at Udemy)
Udemy
Zeal is one of my favorite author for docker. Please try to yourself 💖
(Tip: HE is ready to give some discount for students 😜)
Hi buddy, this is all are intermediate points. if you need to basic understanding please look at my previous docker beginner blog otherwise please ignore
-----------------Table of content-----------------
Docker file
COPY VS ADD
EXPOSE
HEALTH CHECK
ENTRY POINT
WORKDIR
ENV
TAG
Docker commit
layer of docker images
Inspect
Prune
Flattening image
Docker registry
Apply the filters
16.Moving the image across the host
17.Build cache
1.Docker file
Every docker container based on images. Images based on docker files.
Docker files contain the set of commands and microservice procedures. Docker file start FROM instructions its is a base image
FROM busybox
ENV NGINX 1.2
RUN touch web-$NGINX.txt
CMD ["/bin/sh"]
** 2. COPY VS ADD **
Both command are copy the file from local to inside the container but depends on need it will change.
COPY = copy the files from local to inside the container
ADD = get the files from website like application zip files then
unzip the exact destination
COPY src dest
** 3. EXPOSE **
Expose command used for port documentation. Its helps to where we are going to run the port.so clear about the port mapping
EXPOSE port-no
4. HEALTH CHECK
Health check is testing our application healthy or not. Its check some argument and true or false condition.
Condition is true application is healthy whether condition is false application is un-healthy
HEALTHCHECK --interval=35s --timeout=4s CMD curl -f https://localhost/ || exit 1
5. ENTRY POINT
In Docker files, an ENTRYPOINT instruction is used to set executables that will always run when the container is initiated. Unlike CMD commands, ENTRYPOINT commands cannot be ignored or overridden—even when the container runs with command line arguments stated
Once container is start we will give the dynamic command options in entry point section
ENV name Darwin
ENTRYPOINT ["/bin/echo", "Welcome, $name"]
6. WORKDIR
Containers default working directory is called WORKDIR. once execute the container we launch directly in which one we mention the WORKDIR argument.
WORKDIR destination
7. ENV
ENV is a similar like system environment variable. Its works like key and value pair options inside of the container. We pass the dynamic value instead of ENV.
ENV command
8. TAG
Tag the image for reference. Help to improve the image information and maintenance
tag image-id tag-name
9. Docker commit
clone the running docker container for version maintenance and reusability.
docker commit container-id
10. layer of docker images
Docker is the layer architecture so each docker file line represent the layer.Layer have a unique information
*11. Inspect *
Docker image have a lot of information include date,command,size and os architect see the all info associate with the docker image.
docker inspect
12. Prune
Clean-up the dangling and unused images with prune.It's helps to reduce the unused images and increase the system memory.
docker prune
12. Flattening image
Use to create the single layer image.Its helps to manage the storage.single layer of image and fulfill the all requirement
FROM debian:wheezy WORKDIR /tmp RUN wget -nv http://centurylinklabs.com/someutility-v1.0.0.tar.gz && \ tar -xvf someutility-v1.0.0.tar.gz && \ mv /tmp/someutility-v1.0.0/someutil /usr/bin/someutil && \ rm -rf /tmp/someutility-v1.0.0 && \ rm /tmp/someutility-v1.0.0.tar.gz
13. Docker registry
Its help to maintain the image version in repository.similar to github method.we have two option private and public repository. push pull and tag in options are available with repository.
15. Apply the filters
Public repository have a so many options in images.official and unofficial image options are available so filiter help to getting the exact image option.
docker search image name
--filter , -f Filter output based on conditions provided
--format Pretty-print search using a Go template
--limit number Max number of search results
--no-trunc Don't truncate output
16.Moving the image across the host
It helps to move the image one environment to another one.
first archive and load the file then move the tar file.
docker save myapp > myapp.tar
docker load < myapp.tar
17.Build cache
Already we discuss docker is the layer architecture so each and every layer have a individual build structure .
Rebuild the same images multiple times that time docker refer to the cache. its save the build time.rather than we add the new step for same docker image that time only docker build again.
Top comments (0)