Note: remove boot2docker or other Docker implementations if any were previously installed
- Move Docker to your Applications and open the App
- Change
config/database.yml.example
toconfig/database.yml
and configure it for your environment - Open Terminal navigate to the root of the app and run
docker-compose build
- Run
docker-compose up
- Open a browser to localhost:3000 verify the app is up.
docker-compose up
Starts fresh containers-d
starts it in daemon modedocker-compose down
Stops and removes containers(all data too)docker-compose stop
Stops running containers but persists datadocker-compose start
Starts containers with persisted datadocker system prune
Cleans up unused containers, networks, and images-a
removes all
Note: it is recommended to run the clean up commands weekly
docker ps
Lists all running containersdocker-compose run app bash
Starts a bash session on app, bringing up only dependent services.docker exec -it ID_FROM_DOCKER_PS bash
. Connects another bash session to a running container.docker attach ID_FROM_DOCKER_PS
Attach is useful for pry debugging in a running container
Note: To detach use
ctrl-p + ctrl-q
Now that the app is running in Docker we will run all Rails and Rake commands in the container.
Here are a few examples:
Note: this is expecting the containers are up
docker-compose exec app bundle exec rake db:migrate
docker-compose exec app bundle exec rails c
The pattern is docker-compose exec (container_name) rails or rake command. This pattern works for non-Rails commands also.
docker-compose exec app bash
will open the terminal on the container
System tests open the browser and make assertions against the content of the page or verify expected behavior. These tests can be run in headless mode (the default), which means that they are executed in a virtual browser. If you would like them to be run in an actual, viewable browser, you will need to disable headless mode by setting the HEADLESS environment variable to 'false' and ensure you have the ChromeDriver WebDriver downloaded and installed on your host machine.
E.g. HEADLESS=false bundle exec rspec spec/system/mytest_spec.rb
If you are running in non-headless mode, you'll need to be sure you have the ChromeDriver running and able to accept connections from the IP the server is running on. This can be done by running ChromeDriver in a separate tab/console via:
./chromedriver --whitelisted-ips