Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. 108
  2.  
  3. The other answers to restarting a single node are on target, docker-compose restart worker. That will bounce that container, but not include any changes, even if you rebuilt it separately. You can manually stop, rm, create, and start, but there are much easier methods.
  4.  
  5. If you've updated your code, you can do the build and reload in a single step with:
  6.  
  7. docker-compose up --detach --build
  8. That will first rebuild your images from any changed code, which is fast if there are no changes since the cache is reused. And then it only replaces the changed containers. If your downloaded images are stale, you can precede the above command with:
  9.  
  10. docker-compose pull
  11. To download any changed images first (the containers won't be restarted until you run a command like the up above). Doing an initial stop is unnecessary.
  12.  
  13. And to only do this for a single service, follow the up or pull command with the services you want to specify, e.g.:
  14.  
  15. docker-compose up --detach --build worker
  16. Here's a quick example of the first option, the Dockerfile is structured to keep the frequently changing parts of the code near the end. In fact the requirements are pulled in separately for the pip install since that file rarely changes. And since the nginx and redis containers were up-to-date, they weren't restarted. Total time for the entire process was under 6 seconds:
  17.  
  18. $ time docker-compose -f docker-compose.nginx-proxy.yml up --detach --build
  19. Building counter
  20. Step 1 : FROM python:2.7-alpine
  21. ---> fc479af56697
  22. Step 2 : WORKDIR /app
  23. ---> Using cache
  24. ---> d04d0d6d98f1
  25. Step 3 : ADD requirements.txt /app/requirements.txt
  26. ---> Using cache
  27. ---> 9c4e311f3f0c
  28. Step 4 : RUN pip install -r requirements.txt
  29. ---> Using cache
  30. ---> 85b878795479
  31. Step 5 : ADD . /app
  32. ---> 63e3d4e6b539
  33. Removing intermediate container 9af53c35d8fe
  34. Step 6 : EXPOSE 80
  35. ---> Running in a5b3d3f80cd4
  36. ---> 4ce3750610a9
  37. Removing intermediate container a5b3d3f80cd4
  38. Step 7 : CMD gunicorn app:app -b 0.0.0.0:80 --log-file - --access-logfile - --workers 4 --keep-alive 0
  39. ---> Running in 0d69957bda4c
  40. ---> d41ff1635cb7
  41. Removing intermediate container 0d69957bda4c
  42. Successfully built d41ff1635cb7
  43. counter_nginx_1 is up-to-date
  44. counter_redis_1 is up-to-date
  45. Recreating counter_counter_1
  46.  
  47. real 0m5.959s
  48. user 0m0.508s
  49. sys 0m0.076s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement