Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rails in docker

175 views

Published on

Dockerizing a rails app and developing in it.

Start with an existing rails app (or rails new), build an image, start it, make and see changes to your running app

Published in: Technology
  • Be the first to comment

Rails in docker

  1. 1. Rails in Docker Dockerizing and developing Andrew Klotz @klotzandrew
  2. 2. What is docker? - Package code, with environment, and dependencies - Docker images - Containers run images
  3. 3. What you need to install ● docker ● docker-compose ● docker-machine ● https://docs.docker.com/docker-for-mac
  4. 4. docker-machine ● eval $(docker-machine env default) ● docker-machine ls
  5. 5. Dockerized rails Ruby container ● Ruby ● Build ourselves Database container ● PostgreSQL ● Use official image
  6. 6. Docker image for rails ● Rails new or existing app ● Add a Dockerfile (touch Dockerfile)
  7. 7. ● Connect to containerized db in config/database.yml
  8. 8. Database ● official postgres image ● docker run --name db postgres ● docker ps
  9. 9. Docker orchestration - vim docker-compose.yml - docker-compose up
  10. 10. Check it out! ● visit (docker-machine ip):3000 ● docker ps ● see live code changes in the container ● run commands with a container ○ docker exec -it dockerrails_web_1 rails test ○ docker exec -it dockerrails_web_1 bash
  11. 11. Recap ● vim Dockerfile ● vim database.yml ● vim docker-compose.yml ● docker-compose up

×