Docker Community Forums

Share and learn in the Docker community.

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


(Guirec Corbel) #1

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!


(eBuildy) #2

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


(Dvohra) #3

" 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