Reputation: 3049
I'm currently reading Deploying Rails with Docker, Kubernetes and ECS. In the book a Rails image from Dockerhub is use to create a new application. After running the following command a Rails application is created.
docker run -it --rm --user "$(id -u):$(id -g)" -v "$PWD":/usr/src/app -w / usr/src/app \
rails rails new --skip-bundle --api --database postgresql webapp
However, Docker needs this path /usr/src/app
but this is only on Windows. In Mac OS the folder is /usr/local/
should a app
directory be created in local
to follow along this path?
Upvotes: 0
Views: 1773
Reputation: 2254
What's inside docker is a totally separate thing from what's happening on your host system. You should leave this "$PWD":/usr/src/app
as it is now, because the tutorial will certainly be based on that path.
One word of a note concerning $PWD
It's always easier to read and more consistent if you specify the path directly. Meaning if your project has a directory where all the rails app is setup, you are better off writing such a thing:
[..] -v ./ruby-app-directory:/usr/src/app [..]
or
[..] -v .:/usr/src/app [..]
for example:
$ docker run -it --rm --user "$(id -u):$(id -g)" -v .:/usr/src/app -w / usr/src/app \
rails rails new --skip-bundle --api --database postgresql webapp
than leaving it to the variable.
Example
application tree:
root
- one-app
+ some.sh
+ Dockerfile
- second-app
+ some.rails
+ Dockerfile
With above application tree configuration you can use it like this:
$ docker run -it --rm --user "$(id -u):$(id -g)" -v ./second-app:/usr/src/app -w / usr/src/app \
rails rails new --skip-bundle --api --database postgresql webapp
and everything that's inside ./second-app
will be placed inside the container in /usr/src/app
location (with /usr/src/app as a working directory set up by another argument) so that the command you specify at the end of a docker run
command, will be executed in /usr/src/app
- the working directory.
Upvotes: 1