
Travis
Docker For Rails Developers - Chapter 2 Defining Our First Custom Image WORKDIR Correctoin
Dockerfile:
FROM ruby:2.6
RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs
COPY . /usr/src/app/
WORKDIR /usr/src/app/
RUN bundle install
The Dockerfile instructs us to copy the current directory into /usr/src/app/
. Placing our directory myapp into /usr/src/app/
.
Then the WORKDIR is defined as /usr/src/app/
And RUN bundle install
.
This fails as bundle install
should be run in the app directory. We’re in /usr/src/app/
but we should be in /usr/src/app/myapp
.
The Dockerfile is corrected with
FROM ruby:2.6
RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs
COPY . /usr/src/app/
WORKDIR /usr/src/app/myapp
RUN bundle install
Most Liked

Travis
I ended up with a different solution and believe my original problem was a wrong file structure.
My Dockerfile is now located in the Rails app - myapp. The value of WORKDIR
is /usr/src/app/
.
Is that how you have yours now?

jetsondavis
I made the change you suggest, now get this:
/usr/local/bundle/gems/webpacker-4.3.0/lib/webpacker/configuration.rb:95:in `rescue in load’: Webpacker configuration file not found /usr/src/app/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /usr/src/app/config/webpacker.yml (RuntimeError)
Can anyone help? Frustrating to pay so much for a book that is incorrect.

edruder
-
myapp
should be your current directory. (cd myapp
) - The
Dockerfile
should be created in themyapp
directory–it looks like you created it one directory above. -
docker build .
will then succeed, I think.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /c
- /julia
- /slackware
- /neovim