Posts

Showing posts with the label docker

Understanding a Dockerfile

Image
  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...

Rails Application with Docker

Image
Creating Rails App We are creating a rails application without installing rails on our system Create a folder on machine where we want to create Rails app Linux  mkdir ~/docker_rails cd  ~/docker_rails Windows  mkdir docker_rails cd docker_rails Create docker container based on image ruby:2.6   docker run -i -t --rm -v ${PWD}:/usr/src/app ruby:2.6 bash   Where docker run creates a container -i -t OR  -it :    --rm : It's a throwaway container  -v Mounts volume to share local system with container  ${PWD} :  Unix environment variable pointed to current directory Windows user should give current directory path as below docker run -i -t --rm -v C:/Users/amrut/OneDrive/Desktop/Amruta/docker_rails :/usr/src/app ruby:2.6 bash   ${PWD}:/usr/src/app : Mount the current directory inside the container at /usr/src/app Ruby:2.6 Reference docker image bash   After running this command , we can see  root@05d3878962ce:/# This shows...

Docker Tutorial

Image
Docker Tutorial Creator: Amruta Ashish Pednekar A tool to automate the deployment of the application in containers so that the application can work in different environments. Installation on Ubuntu Open terminal Remove any docker file running $ sudo apt-get remove docker docker-engine docker.io Update system sudo apt-get update Install docker and its dependencies sudo apt install docker.io sudo snap install docker docker — versions Pull an image from docker hub sudo docker run hello-world Check the docker image sudo docker images Display all docker containers sudo docker ps -a Check for containers in running state sudo docker ps Installation on Windows https://docs.docker.com/desktop/windows/install/ Download Docker desktop for windows https://hub.docker.com/editions/community/docker-ce-desktop-windows/ Run downloaded .exe installer Check below option Install required Windows components for WSL 2     Add shortcut to desktop Install After installation , it will ask to restart O...