What is Dockerfile, image, container !

What is Dockerfile, Docker Image and container ?

When I started reading about Docker, I was confused about the relationship between Docker file vs docker image vs docker container !

Short answer to my question is:

  • 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