Home Bulid Tool Docker DockerFile Commands

DockerFile Commands

dockerize the MERN stack application

Docker File
A Dockerfile is a text document containing commands used to bulid an image. Every command that is named on the command line will be used. By reading the Dockerfile instructions, Docker automatically constructs photos.
Typical docker file
#The base image
FROM ubuntu:latest
#This instructions means install software and copy files into the image.
COPY /myapp/target/myapp.jar /myapp/myapp.jar
#The command executed when running a Docker container based on this image.
CMD echo Your Docker Container is starting

A Docker image is composed of layers. To the final Docker image, each layer contributes something. Each layer is a different Docker image, actually. Thus, one or more underlying Docker images consist of your Docker file, on top of which you apply your own layers.
Docker file instruction
The instructions are not case-sensitive, but conventions that suggest uppercase use must be followed. Docker runs Dockerfile instructions in top to bottom order. In order to determine the Base Image, the first instruction must be FROM.

  1. FROM
    Usage : FROM ubuntu:latest
    This instruction is used to set the Base Image for the instructions that follow. It must have FROM as its first instruction for a proper Dockerfile.
  2. LABEL
    Usage : LABEL vendorl = "onurdesk"
    A label, stored as a string, is a key-value pair. You may designate several labels for an object, but within an object, each key-value pair must be identical. If several values are given to the same key, the most-recently-written value overwrites all previous values.
  3. RUN
    Usage : RUN /bin/bash -c 'source $WORK/.bashrc; echo $WORK'
  4. CMD
    Usage : CMD ["runnable", "param1", "param2"?]
    This is used to perform the image implementation. We should still use CMD in the form above.
  5. COPY
    Usage : COPY current-location/ /target-location
    This command is used to copy the file of folder from source to destination.
    Usage: WORKDIR /etc/var/html
    The WORKDIR is used to set the working directory in the Dockerfile for every RUN, CMD, and COPY instructions that follow it. If there is no active directory, it will be created by default.



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Exit mobile version