Docker-compose does not reflect changes in requirements.txt
I think the problem likely is that $ docker-compose up
alone will not rebuild your images if you make changes. In order to get docker-compose
to include your changes to your requirements.txt
you will need to pass the --build
flag to docker-compose
.
I.e instead run:
docker-compose -f docker-compose-dev.yml up --build -d
Which will force a docker-compose
rebuild the image. However this will rebuild all images in the docker-compose
file which may or may not be desired.
If you only want to rebuild the image of a single service you can first run docker-compose -f docker-compose-dev.yml build web
, then afterwards just run your original docker-compose
command.
More info on the build
command here.
Try to install requirements from the copied file
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
It is an example of their Dockerfile
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
This is what you have
RUN pip install -r requirements.txt
Then after you have changed your docker file, you have to stop your container, remove your image, build a new one, and run container from it.
Stop container and remove the image.
docker-compose down
docker-compose --rmi all
--rmi all
- removes all images. You might want to use --rmi IMAGE_NAME
And to start it (if you use not default parameters, change these commands with your arguments).
docker-compose up
Update
In case you have running docker and you do not want to stop it and rebuild an image (if you just want to install a package or run some commands or even start a new application), you can connect the container from your local machine and run command line commands.
docker exec -it [CONTAINER_ID] bash
To get [CONTAINER_ID]
, run
docker ps
Note docker-compose ps
will give you containers names, but you need container id to ssh the container.