Before you run the application using Compose, notice that this Compose file specifies a `password.txt` file to hold the database's password. You must create this file as it's not included in the source repository.
In the cloned repository's directory, create a new directory named `db` and inside that directory create a file named `password.txt` that contains the password for the database. Using your favorite IDE or text editor, add the following contents to the `password.txt` file.
```text
mysecretpassword
```
Save and close the `password.txt` file. In addition, in the file `webapp.env` you can change the password to connect to the database.
You should now have the following contents in your `docker-ruby-on-rails`
directory.
```text
.
├── Dockerfile
├── Gemfile
├── Gemfile.lock
├── README.md
├── Rakefile
├── app/
├── bin/
├── compose.yaml
├── config/
├── config.ru
├── db/
│ ├── development.sqlite3
│ ├── migrate
│ ├── password.txt
│ ├── schema.rb
│ └── seeds.rb
├── lib/
├── log/
├── public/
├── storage/
├── test/
├── tmp/
└── vendor
```
Now, run the following `docker compose up` command to start your application.
```console
$ docker compose up --build
```
In Ruby on Rails, `db:migrate` is a Rake task that is used to run migrations on the database. Migrations are a way to alter the structure of your database schema over time in a consistent and easy way.
```console
$ docker exec -it docker-ruby-on-rails-web-1 rake db:migrate RAILS_ENV=test
```
You will see a similar message like this:
`console
== 20240710193146 CreateWhales: migrating =====================================
-- create_table(:whales)
-> 0.0126s
== 20240710193146 CreateWhales: migrated (0.0127s) ============================
`
Refresh <http://localhost:3000> in your browser and add the whales.
Press `ctrl+c` in the terminal to stop your application and run `docker compose up` again, the whales are being persisted.
## Automatically update services
Use Compose Watch to automatically update your running Compose services as you
edit and save your code. For more details about Compose Watch, see [Use Compose