There are scope of services which defined in docker-compose.yml. These service have been started. I need to rebuild only one of these and start it without up other services. I run the following commands:
docker-compose up -d # run all services
docker-compose stop nginx # stop only one. but it still running !!!
docker-compose build --no-cache nginx
docker-compose up -d --no-deps # link nginx to other services
At the end i got old nginx container. By the way docker-compose doesn't kill all running containers !
For me it only fetched new dependencies from Docker Hub with both
--no-cache
and--pull
(which are available fordocker-compose build
.As @HarlemSquirrel posted, it is the best and I think the correct solution.
But, to answer the OP specific problem, it should be something like the following command, as he doesn't want to recreate ALL services in the
docker-compose.yml
file, but only thenginx
one:Options description:
Simply use :
Replace
[yml_service_name]
with your service name indocker-compose.yml
file. You can usedocker-compose restart
to make sure changes are effected. You can use--no-cache
to ignore the cache.docker-compose up
With docker-compose 1.19
up
Without one or more
service_name
arguments all containers will be rebuiltFrom the help menu
The problem is:
didn't work (you said it is still running). If you are going to rebuild it anyway, you can try killing it:
If it still doesn't work, try to stop it with docker directly:
or delete it
If that still doesn't work, check your version of docker, you might want to upgrade.
It might be a bug, you could check if one matches your system/version. Here are a couple, for ex: https://github.com/docker/docker/issues/10589
https://github.com/docker/docker/issues/12738
As a workaround, you could try to kill the process.