Skip to content

Common Tasks

Mark Bussey edited this page Feb 1, 2019 · 16 revisions

Commands to run from your host machine

Run these commands from the hyrax_demo directory of your host system – i.e., not inside the container.

  • Stop the containers if they're running: docker-compose down

  • Start the containers if they're not running: docker-compose up

  • Connect to a web container to run ruby commands: docker-compose run web bash

    Note that this doesn't actually connect to the container that's running your web server. Instead, it creates a _new_ container based on the same image. This is the docker philosophy of keeping things isolated – _contained_, if you will.
  • Run a single command in a container: docker-compose run web [command]

    e.g. docker-compose run web rake db:setup

  • Wipe out everything and start over

    docker-compose down --volumes (or just docker-compose down -v)

    The `--volumes` bit tells docker to destroy all your data volumes. This includes your Fedora, Solr, and mysql data, so make sure you only do this if that's what you want!
  • See the output from a single container docker-compose logs [container] e.g. docker-compose logs web

  • Restart the rails server

    docker-compose restart web

Editing files

  1. This tutorial assumes that you run the examples within your container from the ./hyrax_demo directory
  2. The entire /hyrax_demo directory in your container is mounted from the same directory on your host machine (laptop), so you can use your favorite editor or IDE to edit files easily at path-you-started-from-on-your-host-system/hyrax_demo
  3. Inside the guest machine, you can also use common Linux editors like vim and nano to edit files.

Commands to run inside a container

Unless otherwise noted, these should be run inside your web container – e.g., in a shell you opened with docker-compose run web bash.

  • Start a Rails console

    1. Type rails console to enter the console (or rails c for shorthand)
  • Run any outstanding / new database migrations

    1. Type rails db:migrate
  • Reset your development repository to a completely empty state

    rails db:drop
    rails db:migrate
    rails console
    # inside the rails console from the irb> prompt
    require 'active_fedora/cleaner'
    ActiveFedora::Cleaner.clean!
    exit
    # back at your bash # prompt 
    rails hyrax:default_admin_set:create