AndroidOthersquestionsTechnical blogTravelTrending

What is a Docker file, image, container !

When I started reading about Docker, I was confused about the relationship between Docker file vs docker image vs docker container !
  • Docker file is where I need to script my steps on what actions to be done before I make a docker image.
    a sample docker file as below: here below in the code, I am pulling JDK environment in line 1. copying a java class to app directory in line 2, setting app as working directory in line 3 for my docker container after i convert image to container. Then finally running my app in line 4.
    FROM java:8-jdk-alpine
    COPY HelloWorl.class /app/
    WORKDIR /app
    ENTRYPOINT [“java”,”HelloWorld”]
  • Docker image is created using the above docker file by building it. (command : docker build -t myhelloworldapp . )
  • then spin up the container by using command : docker run myhelloworldapp
  • Knowledge courtesy : Taji Philip.