I am working on a project that uses docker-compose up
to start up and run. I am not very familiar with docker-compose and I couldn't really find an answer in the docs. According to the docs the up
command rebuilds the container from the docker file, however this does not seem to happen.
When I try to add print
commands for debugging nothing happens. The program already throws a few print commands and I tried changing those to be sure, and they always print the same. Do I have to add something to the up
command to make the container rebuild?
docker-compose/yml:
dockbrato:
build: .
volumes:
- "/sys:/sys"
- "/var/run/docker.sock:/var/run/docker.sock"
As far as I can tell,
docker-compose up
only builds images that don't exist already; it will not rebuild an image whose source has changed. If you want to rebuild your image, rundocker-compose build
beforedocker-compose up
.I had a similar problem with Docker version 1.3 and Docker Compose version 1.22 on CentOS 7. I could resolve the problem by upgrading to Docker version 18.06. To do this, I took the following steps. First, I removed the old version of Docker by running the following command:
Then, I set up required repositories:
and finally installed the latest CE version:
After upgrading Docker, I removed containers built based on the old version of Docker by running this command:
Running
docker-compose up
rebuilt the containers. Afterward, changing the code was successfully reflected in the desired container.