- Install docker
- Install docker-compose
- Don't forget Post-install section (for linux)
- Add an alias for
docker-compose
for ease use
echo "alias dcdev='docker-compose -f docker-compose-dev.yml'" >> ~/.bashrc
# For Oh My Zsh
echo "alias dcdev='docker-compose -f docker-compose-dev.yml'" >> ~/.zshrc
- Reload your rc file
. ~/.bashrc
# For Oh My Zsh
. ~/.zshrc
- For Redis, add
vm.overcommit_memory = 1
to your/etc/sysctl.conf
- Copy and edit
.env
file
cp docker_dev/.env_docker.example docker_dev/.env_docker
- Build an image
dcdev build
- Run app
dcdev up
- Create a Database and run migrations
dcdev run web bundle exec rails db:setup
# or
dcdev run web bundle exec rails db:create
dcdev run web bundle exec rails db:schema:load
dcdev run web bundle exec rails db:seed
- Run
dcdev up
and you are good to go. - To run any Rails related command, just shell
dcdev run web bash
and execute anything you want inside container. - You can use or add any aliases you want, see
docker_dev/Dockerfile
. Don't forget to rebuild an image: Rundcdev down
to stop everything anddcdev build
to rebuild - You might have an issues on Linux OS with permissions on files that created by Docker. Just run chown
sudo chown -R YOUR_USER:YOUR_GROUP .
- Place
binding.pry
or any other debugger in a place you need - Run
docker attach CONTAINER_NAME_web_1
to access console (Note that there might be some issues, see docker/compose#423 (comment))