Docker and Kubernetes

Ludmila Korchnoy
2 min readFeb 19, 2021

I have attended DeveloperWeek 2021 and found it very informative. My interest was captured mainly by Kubernetes which makes it easy to orchestrate containers. Docker is container. You can build and deploy your application with Docker. “Accelerate going from code to Cloud with Docker Desktop and Microsoft. Docker and Microsoft have simplified the developer flow of bringing container applications from your local machine and running them in Azure Container Instances.” (docker.com) or deploy it to a container hosting service Elastic BeanStalk with AWS. Great reference to check out new home for Kubernetes community https://operatorhub.io/

This are the steps I took to create Docker container in my rails app (I used Mac):

1. Sign up for Docker Hub, Docker id is your unique username and install Docker from https://docs.docker.com/get-docker/

The app will run inside the Docker container as well as it’s dependencies.

2. Create .dockerignore file and include:

.git.gitignoreREADME.md ## OS X#.DS_Store.AppleDouble.LSOverride# Icon must end with two \rIcon# Thumbnails._*# Files that might appear on external disk.Spotlight-V100.Trashes# Directories potentially created on remote AFP share.AppleDB.AppleDesktopNetwork Trash FolderTemporary Items.apdisk ## Rails#.env.env.sample*.rbccapybara-*.htmllogtmpdb/*.sqlite3db/*.sqlite3-journalpublic/systemcoverage/spec/tmp**.orig .bundle .ruby-version.ruby-gemset .rvmrc # if using bower-rails ignore default bower_components path bower.json filesvendor/assets/bower_components*.bowerrcbower.json

3.Create your Dockerfile and enter the following code:

FROM rubyWORKDIR /home/appENV PORT 3000EXPOSE $PORTRUN gem install rails bundler
RUN gem install rails
RUN apt-get update -qq && apt-get install -y nodejs
ENTRYPOINT [ "/bin/bash" ]4. Create docker-compose.yml file and include:version: "3.9"services:ruby_dev:build: .container_name: ruby_containerports:- "3000:3000"volumes:- ./:/home/appWhen installing Docker app follow the instructions in the app: docker/getting-started

Run the following commands in your terminal:

docker-compose build

docker-compose run --rm --service-ports ruby_dev

rails new myapp && cd myapp

bundle update && bundle install

rails server -p $PORT -b 0.0.0.0

You should see Yay! You're on Rails!

The next step would be to run the app using container hosting service which should be easy and smooth.

--

--

Ludmila Korchnoy

Hello World! I’m a Full stack web developer experienced in Ruby and JavaScript frameworks. I graduated Flatiron School in October of 2020.