Dockerfile cmd returns Yarn integrity error but Docker run works fine

making config.webpacker.check_yarn_integrity = false is not a good idea.

It occurs due to version incompatibility.

try

rails webpacker:install

It should solve your problem.


if not try

$ rm yarn.lock
$ yarn cache clean
$ yarn install

You can compare your Dockerfile+docker-compose.yml with this one and see if there is nay difference (like using RUN yarn install --check-files) which would make the error message disappear.

Another example (Dockerfile+docker-compose.yml) is used in "Running a Rails app with Webpacker and Docker" from Dirk de Kok

In both instances, the application is started with docker-compose up.
And they have followed, as you have, the recommendations of rails/webpacker issue 1568 (regarding config.webpacker.check_yarn_integrity = false in config/environments/development.rb)


It worked today. No code was changed, it just decided to work. I tried running docker-compose run web rm -rf / to start over, but it ignored that command then started working. C'est la vie. @vonc thanks for the effort, I'll reward you.

Edit: It returned. This time I fixed it using

docker rm $(docker ps -a -q)

Warning: This destroys all your containers. Do not use this if you have data inside your volumes.

The cause of the problem was experimenting with creating a Dockerfile and the compose was not clearing out a layer of the volume. docker-compose run is different than docker-compose up because run creates a new layer on top of the docker volume to execute the command, essentially creating a new container. Docker itself was failing to apply the changes to an old layer.