How to exec a command on a container created by docker-compose?

Hello,

It’s probably a stupid question but I’m new with docker and I don’t understand by reading the doc.

I created a new Rails project by following this tutorial. The server respond successfully. I changed my Gemfile and I want to bundle again so I do docker-compose run web bundle. That command create a new container and, when I do a docker-compose, it don’t use this container. It use an older without changes.

I just want to exec a command an keep changes. Is there a simple way ?

Thanks!

docker run creates a new container, with the same volumes and dependencies of the docker-compose definition.

" I changed my Gemfile and I want to bundle again so I do docker-compose run web bundle. That command create a new container"

Some issues with the preceding:

Whenever the Gemfile is modified the docker-compose build command must be re-run, not docker-compose run web bundle, to regenerate the Docker image, not the Docker container as indicated.

docker-compose build

Subsequently, start/boot the Docker Compose application with the following command.
docker-compose up