Unexpected behaviour docker-compose VS docker

Mi rails project image works perfect when I build and run, BUT when I use docker-compose:

  • docker-compose build works fine
  • docker-compose run throws the following exception:
web_1       | Bundler::LockfileError: You must use Bundler 2 or greater with this lockfile.
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/lockfile_parser.rb:108:in'warn_for_outdated_bundler_version'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/lockfile_parser.rb:95:in 'initialize'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:83:in 'new'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:83:in 'initialize'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/dsl.rb:218:in 'new'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/dsl.rb:218:in 'to_definition'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/dsl.rb:13:in 'evaluate'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:35:in 'build'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:135:in 'definition'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:101:in 'setup'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/bundler/setup.rb:20:in '<top (required)>'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in 'require'
web_1       |   /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in 'require'

Thats weird! Because when I build and run the same folder with docker (not docker-compose) everything goes fine…

Please… any help?
My docker-compose.yaml content:

version: '3'

    services:
      web:
    build: .
    ports:
      - "3027:3027"
    volumes:
      - .:/usr/src/app
      - gem_cache:/gems
    env_file:
      - .env/development/database
      - .env/development/web

      database:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    ports:
      - "3306:3306"
    volumes:
      - dbdata:/var/lib/mysql
    env_file:
      - .env/development/database

    volumes:
      gem_cache:
      dbdata: 

Finally I solved it:

  1. gem uninstall bundler, and i selected the 2.0.1 version. And not delete the executable file (prompted question at the unninstalling).
  2. gem install bundler -v '1.17.3'
  3. Rebuild the images, and everything works correct again!