Understanding a Dockerfile

 

Understanding a Dockerfile

Dockerfile describes exactly how the docker image should be constructed. It is made up of various instructions such as  FROM, RUN, COPY, and WORKDIR.

  • FROM : Image to use as its starting point. Our Image is based on ruby:2.6

  • RUN : Tells Docker to execute commands

    • apt-get : Linux command to install software

    • -y : Answers YES to any prompts

    • -qq  : Enables QUIET mode to reduce printed output

    • Installs nodejs - A prerequisite of running Rails

    •  --no-install-recommends : Not to install other non essential packages

    • We don't need sudo here because commands inside the container by default runs by root user

  • COPY . /usr/src/app/ 

    • Copy all files from current directory (.) to /usr/src/app

    • Copies Rails application into container at /usr/src/app

    • Source path is depends on where our Dockerfile is located

  • WORKDIR /usr/src/app : 

    • Container default working directory is /

    • Change working directory to /usr/src/app

  • RUN bundle install : 

    • Executes from container’s directory /usr/src/app

    • Install all gems defined in Gemfile, needed to start the application

  • Go to root path of rails application and create this Dockerfile 


Comments

Popular posts from this blog

PERSONAL ACCESS TOKEN ON GITHUB

Docker Tutorial

Software Installation on Ubuntu