This draining approach works great for the majority of cases. But every once in a while, you need a little more control over the shutdown process — especially when you have long-lived sessions, such as WebSockets or HTTP long polling. The problem with long-lived WebSocket sessions is that the Application Load Balancer (ALB) starts to forcibly kill all “still active” connections once the draining period has elapsed. By the time the application receives a SIGTERM, the long-lived connections may have already been terminated by the ALB. This makes it impossible to close them gracefully on the application side. This doesn’t have to be a big problem. The long-lived WebSockets will be closed abnormally — which would lead to 1006 Abnormal Closure code on the server and the client. But that’s all. Clients will reconnect to another healthy task and continue to operate normally.
Windows 10 10 月の更新プログラム2018以降、開発/テストのために Windows 10 Enterprise または Professional で windows コンテナーをプロセス分離モードで実行することをユーザーに許可しなくなりました。 詳細については、 FAQを参照してください。Windows Server のコンテナーでは、運用環境で使用されるものと同じカーネルバージョンおよび構成を開発者に提供するために、Windows 10 で既定で Hyper-v 分離を使用します。
PS > docker-compose up Creating network "docker_compose_default" with the default driver
…略…
Attaching to docker_compose_web_1, docker_compose_redis_1 redis_1 | 1:C 14 Dec 201918:22:40.379# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo redis_1 | 1:C 14 Dec 201918:22:40.379# Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1, just started redis_1 | 1:C 14 Dec 201918:22:40.379# Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf redis_1 | 1:M 14 Dec 201918:22:40.379 * Running mode=standalone, port=6379. redis_1 | 1:M 14 Dec 201918:22:40.380# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. redis_1 | 1:M 14 Dec 201918:22:40.380# Server initialized redis_1 | 1:M 14 Dec 201918:22:40.380# WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. redis_1 | 1:M 14 Dec 201918:22:40.380 * Ready to accept connections web_1 | * Serving Flask app "app.py" (lazy loading) web_1 | * Environment: development web_1 | * Debug mode: on web_1 | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) web_1 | * Restarting with stat web_1 | * Debugger is active! web_1 | * Debugger PIN: 318-738-267 web_1 | 172.20.0.1 - - [14/Dec/201918:23:32] "GET / HTTP/1.1"200 - web_1 | * Detected change in'/code/app.py', reloading web_1 | * Restarting with stat web_1 | * Debugger is active! web_1 | * Debugger PIN: 318-738-267 web_1 | 172.20.0.1 - - [14/Dec/201918:24:49] "GET / HTTP/1.1"200 -
PS > docker-composeps 指定されたパスが見つかりません。 Name Command State Ports ---------------------------------------------------------------------------------------- docker_compose_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp docker_compose_web_1 flask run Up 0.0.0.0:5000->5000/tcp
docker-composeをバックグラウンドで動作させるのはdocker-compose up -d、停止はdocker-compose stop。
web_1 | * Environment: production web_1 | WARNING: This is a development server. Do not use it in a production deployment. web_1 | Use a production WSGI server instead. web_1 | * Debug mode: off web_1 | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) Gracefully stopping... (press Ctrl+C again to force) Stopping docker_compose_web_1 ... done Stopping docker_compose_redis_1 ... done PS > docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7b80daf87099 docker_compose_web "flask run"29 minutes ago Exited (137) 3 minutes ago docker_compose_web_1 73c9ed48c34a redis:alpine "docker-entrypoint.s…"29 minutes ago Exited (0) 3 minutes ago docker_compose_redis_1
PS > docker-compose up Creating network "docker_compose_default" with the default driver
…略…
PS > docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ac1ba1951edb redis:alpine "docker-entrypoint.s…" About a minute ago Up 15 seconds 6379/tcp docker_compose_redis_1 6681c0eff91c docker_compose_web "flask run" About a minute ago Up 15 seconds 0.0.0.0:5000->5000/tcp docker_compose_web_1 PS > docker exec -it ac1ba1951edb /bin/ash /data# /data# ls dump.rdb
PS > docker-compose exec web ash /code # ls Dockerfile app.py requirements.txt __pycache__ docker-compose.yml /code # exit PS > docker-compose exec redis ash /data# ls dump.rdb /data# exit
Containerを起動して一度だけコマンド実行を行う
イメージからContainerを新しく起動する場合はdocker run [イメージ名] [コマンド名]。
1 2 3 4 5 6 7 8 9 10 11
PS > docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker_compose_web latest a460579f2e03 About an hour ago 213MB redis alpine a49ff3e0d85f 3 weeks ago 29.3MB python 3.7-alpine8922d588eec6 4 weeks ago 98.4MB PS > docker run docker_compose_web /bin/ash PS > docker run -it docker_compose_web /bin/ash /code # ls Dockerfile app.py requirements.txt __pycache__ docker-compose.yml /code # exit
docker-composeを使う場合はdocker-compose run [サービス名] [コマンド名]で操作できる。
PS > docker-compose up Creating network "docker_compose_default" with the default driver Creating docker_compose_web_1 ... error
ERROR: for docker_compose_web_1 Cannot start service web: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"flask\": executable file not found in $PATH": unknown
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"flask\": executable file not found in $PATH": unknown ERROR: Encountered errors while bringing up the project. PS > docker-compose build --no-cache Building web Step 1/9 : FROM python:3.7-alpine ---> 8922d588eec6
docker images -aでのみ見えるものがThe Good <none>:<none>でDockerイメージのレイヤー構造に起因したものなのでレイヤー構造を理解しないといけない。The Bad <none>:<none>は他から参照されていないのに存在するゴミでdanglingイメージ(宙ぶらりん?)と呼ばれている。
PS > docker image prune WARNING! This will remove all dangling images. Are you sure you want to continue? [y/N] y Total reclaimed space: 0B PS > docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE docker_compose_web latest 5b84b8389657 29 minutes ago 213MB <none> <none> a781b9ba80ff 29 minutes ago 213MB <none> <none> 1bf5991056e4 29 minutes ago 213MB <none> <none> 73cf869e71e5 29 minutes ago 202MB <none> <none> 64589c0f27d3 29 minutes ago 202MB <none> <none> 7f7e2af72efa 29 minutes ago 98.4MB <none> <none> c220db73c816 29 minutes ago 98.4MB <none> <none> ecccd64cc137 29 minutes ago 98.4MB redis alpine a49ff3e0d85f 3 weeks ago 29.3MB python 3.7-alpine8922d588eec6 4 weeks ago 98.4MB PS > docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7b80daf87099 docker_compose_web "flask run"29 minutes ago Exited (137) 3 minutes ago docker_compose_web_1 73c9ed48c34a redis:alpine "docker-entrypoint.s…"29 minutes ago Exited (0) 3 minutes ago docker_compose_redis_1
次に停止中のContainerを削除する。削除はdocker container pruneでまとめて削除できる。 そのあとにdocker image pruneでイメージのクリーンナップしてもThe Good <none>:<none>が消えることはない。
PS > docker container prune WARNING! This will remove all stopped containers. Are you sure you want to continue? [y/N] y Deleted Containers: 73c9ed48c34aaa7cebf06ae40ceca5c8389675e67798868f7df13e7a51e79840
Total reclaimed space: 461kB PS > docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES PS > docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE docker_compose_web latest 5b84b8389657 45 minutes ago 213MB <none> <none> 1bf5991056e4 45 minutes ago 213MB <none> <none> a781b9ba80ff 45 minutes ago 213MB <none> <none> 64589c0f27d3 45 minutes ago 202MB <none> <none> 73cf869e71e5 45 minutes ago 202MB <none> <none> c220db73c816 45 minutes ago 98.4MB <none> <none> ecccd64cc137 45 minutes ago 98.4MB <none> <none> 7f7e2af72efa 45 minutes ago 98.4MB redis alpine a49ff3e0d85f 3 weeks ago 29.3MB python 3.7-alpine8922d588eec6 4 weeks ago 98.4MB PS > docker image prune WARNING! This will remove all dangling images. Are you sure you want to continue? [y/N] y Total reclaimed space: 0B PS > docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE docker_compose_web latest 5b84b8389657 46 minutes ago 213MB <none> <none> a781b9ba80ff 46 minutes ago 213MB <none> <none> 1bf5991056e4 46 minutes ago 213MB <none> <none> 73cf869e71e5 46 minutes ago 202MB <none> <none> 64589c0f27d3 46 minutes ago 202MB <none> <none> 7f7e2af72efa 46 minutes ago 98.4MB <none> <none> c220db73c816 46 minutes ago 98.4MB <none> <none> ecccd64cc137 46 minutes ago 98.4MB redis alpine a49ff3e0d85f 3 weeks ago 29.3MB python 3.7-alpine8922d588eec6 4 weeks ago 98.4MB
Containerから参照されていないイメージはdocker image prune -aでまとめて削除できる。 今度はdocker image prune -aで削除してみる。The Good <none>:<none>も消えるが、参照されていないすべてのものが消える。
PS > docker image prune -a WARNING! This will remove all images without at least one container associated to them. Are you sure you want to continue? [y/N] y Deleted Images: untagged: redis:alpine untagged: redis@sha256:ee13953704783b284c080b5b0abe4620730728054f5c19e9488d7a97ecd312c5 deleted: sha256:a49ff3e0d85f0b60ddf225db3c134ed1735a3385d9cc617457b21875673da2f0 deleted: sha256:f0bc82535d2e3250dad8edf9a8e5ad9f24ee27744393a2c781d36e785498c844 deleted: sha256:1fbf3f39fa220d3b6981fa59b146ee7c5581d39ffb33d1b45685e55bb5cc4c0b deleted: sha256:48a9a7273f3245a05749ab53f3e5de1721802409fb422419f72c8ca1661869f6 deleted: sha256:e8d9b8d29a84e15b68e4e85f51fe3d50692c5e4cbefa9e7e1005c336734acd55 deleted: sha256:56ee7a6ab270cd80ff8ff38e4a966d311ea53174a60721a62f061efd42c426b3 untagged: docker_compose_web:latest deleted: sha256:5b84b83896579e86516cdae855c5ad88567bef4086c0866575db89944a23783a deleted: sha256:560e8806fc52a1cda02805458af3243aa14ec0dfb2068fd401a0e2b14afa8565 deleted: sha256:1bf5991056e4978695a8cf395e398f8655c02d77225f7df3f9b226d176f2291d deleted: sha256:c9648df40ed18e44c7af492656899b23242a56fd3de3d1e6426f74a5d9c095e3 deleted: sha256:73cf869e71e50d2ef9dda69e8bc23a5275c70194f40534eb831de30fda59eb0e deleted: sha256:cac7e434b98cf26674aa4e2cb6a17d2be78c22cba899689b5b630774c744d2b8 deleted: sha256:64589c0f27d34132e7eda1aa2012acbf7c8f1d461e382069e452481046fff4e4 deleted: sha256:8df494eabb2663ef5ca5cef25ba7a19941b9ea950b38eb74e2e69ad4b55ef1c1 deleted: sha256:c220db73c81631cb3b2b2ab13cd6d5bf36b26dc4069eba1ffda06ca297c83590 deleted: sha256:7f7e2af72efaa4004d49a92afdec5973ba78036be1528c31eb60fd1ad73beda5 deleted: sha256:ecccd64cc1377d9f940b614c4b28a95eec9c071af90b9a1f921e4e0741ff12dc deleted: sha256:b2ed5645e18c07e3cf8998599b78707129f5acaf1d599ab25d5d0a0b236a43a3 untagged: python:3.7-alpine untagged: python@sha256:de9fc5bc46cb1a7e2222b976394ea8aa0290592e3075457d41c5f246f176b1bf deleted: sha256:8922d588eec695e9ec9e7f7cded1eea0760cb6fe7a8e46092ec12ede474f74e1 deleted: sha256:1aa13cc7d1ee07997279eab07ab1647ee0b3fd360c13486f67034b202100dc29 deleted: sha256:f298bab69f60c995202757bcc8691c1905d4d3a713ba22e96aa7369d53172a7d deleted: sha256:7cb29a35ad37814ef19699d89f2e461360c010b9acc33a7467490d038f4a007d deleted: sha256:44a0460612107556df9d2a0a172fae2218986bf496f7cecfdc1354aacca393bc deleted: sha256:77cae8ab23bf486355d1b3191259705374f4a11d483b24964d2f729dd8c076a0
Total reclaimed space: 236.8MB PS > docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES PS > docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE
Containerは停止状態とするが、削除せず存在している状態で、docker image prune -aを試す。Containerからの参照があるので、The Good <none>:<none>を含めすべて残っている。
PS > docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE docker_compose_web latest be361c03fae8 44 minutes ago 213MB <none> <none> 7c27de23c598 44 minutes ago 213MB <none> <none> 729dfa99b333 44 minutes ago 213MB <none> <none> 55ae4fb24b6c 44 minutes ago 202MB <none> <none> 4b9d4224f8df 44 minutes ago 202MB <none> <none> 269867bb5613 44 minutes ago 98.4MB <none> <none> 05447f1997bf 44 minutes ago 98.4MB <none> <none> 52f58b988872 44 minutes ago 98.4MB redis alpine a49ff3e0d85f 3 weeks ago 29.3MB <none> <none> 8922d588eec6 4 weeks ago 98.4MB PS > docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 497b14b9d4a8 redis:alpine "docker-entrypoint.s…"44 minutes ago Exited (0) 43 minutes ago docker_compose_redis_1 cb13ceef58a6 docker_compose_web "flask run"44 minutes ago Exited (137) 43 minutes ago docker_compose_web_1 PS > docker system prune -a WARNING! This will remove: - all stopped containers - all networks not used by at least one container - all images without at least one container associated to them - all build cache
Are you sure you want to continue? [y/N] y Deleted Containers: 497b14b9d4a834770e6315c849e7d314903134f4063d687f1f82d65eb7765cb6 cb13ceef58a603a3a9511890a092df41e1550a96d95aafa26d8ed3abb2a8dd48
Total reclaimed space: 237.4MB PS > docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES PS > docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE
Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}"; "${distro_id}:${distro_codename}-security"; // Extended Security Maintenance; doesn't necessarily exist for // every release and this system may not have it installed, but if // available, the policy for updates is such that unattended-upgrades // should also install from here by default. "${distro_id}ESM:${distro_codename}"; "${distro_id}:${distro_codename}-updates"; // "${distro_id}:${distro_codename}-proposed"; // "${distro_id}:${distro_codename}-backports"; };
// Automatically upgrade packages from these (origin:archive) pairs // // Note that in Ubuntu security updates may pull in new dependencies // from non-security sources (e.g. chromium). By allowing the release // pocket these get automatically pulled in. Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}"; "${distro_id}:${distro_codename}-security"; // Extended Security Maintenance; doesn't necessarily exist for // every release and this system may not have it installed, but if // available, the policy for updates is such that unattended-upgrades // should also install from here by default. "${distro_id}ESM:${distro_codename}"; // "${distro_id}:${distro_codename}-updates"; // "${distro_id}:${distro_codename}-proposed"; // "${distro_id}:${distro_codename}-backports"; };
// List of packages to not update (regexp are supported) Unattended-Upgrade::Package-Blacklist { // "vim"; // "libc6"; // "libc6-dev"; // "libc6-i686"; };
// This option will controls whether the development release of Ubuntu will be // upgraded automatically. Unattended-Upgrade::DevRelease "false";
// This option allows you to control if on a unclean dpkg exit // unattended-upgrades will automatically run // dpkg --force-confold --configure -a // The default is true, to ensure updates keep getting installed //Unattended-Upgrade::AutoFixInterruptedDpkg "false";
// Split the upgrade into the smallest possible chunks so that // they can be interrupted with SIGTERM. This makes the upgrade // a bit slower but it has the benefit that shutdown while a upgrade // is running is possible (with a small delay) //Unattended-Upgrade::MinimalSteps "false";
// Install all unattended-upgrades when the machine is shutting down // instead of doing it in the background while the machine is running // This will (obviously) make shutdown slower //Unattended-Upgrade::InstallOnShutdown "true";
// Send email to this address for problems or packages upgrades // If empty or unset then no email is sent, make sure that you // have a working mail setup on your system. A package that provides // 'mailx' must be installed. E.g. "user@example.com" //Unattended-Upgrade::Mail "root";
// Set this value to "true" to get emails only on errors. Default // is to always send a mail if Unattended-Upgrade::Mail is set //Unattended-Upgrade::MailOnlyOnError "true";
// Remove unused automatically installed kernel-related packages // (kernel images, kernel headers and kernel version locked tools). //Unattended-Upgrade::Remove-Unused-Kernel-Packages "false";
// Do automatic removal of new unused dependencies after the upgrade // (equivalent to apt-get autoremove) //Unattended-Upgrade::Remove-Unused-Dependencies "false";
// Automatically reboot *WITHOUT CONFIRMATION* // if the file /var/run/reboot-required is found after the upgrade //Unattended-Upgrade::Automatic-Reboot "false";
// If automatic reboot is enabled and needed, reboot at the specific // time instead of immediately // Default: "now" //Unattended-Upgrade::Automatic-Reboot-Time "02:00";
// Use apt bandwidth limit feature, this example limits the download // speed to 70kb/sec //Acquire::http::Dl-Limit "70";
// Enable logging to syslog. Default is False // Unattended-Upgrade::SyslogEnable "false";
// Specify syslog facility. Default is daemon // Unattended-Upgrade::SyslogFacility "daemon";
// Download and install upgrades only on AC power // (i.e. skip or gracefully stop updates on battery) // Unattended-Upgrade::OnlyOnACPower "true";
// Download and install upgrades only on non-metered connection // (i.e. skip or gracefully stop updates on a metered connection) // Unattended-Upgrade::Skip-Updates-On-Metered-Connections "true";
marking linux-image-4.15.0-43-generic for removal marking linux-image-4.15.0-38-generic for removal Packages that were successfully auto-removed: Packages that are kept back: Option --dry-run given, *not* performing real actions
…略…
Writing dpkg log to /var/log/unattended-upgrades/unattended-upgrades-dpkg.log
…略…
すべてのアップグレードがインストールされました
…略…
marking linux-image-4.15.0-38-generic for removal Packages that were successfully auto-removed: Packages that are kept back: InstCount=0 DelCount=0 BrokenCount=0
Cloud native computing is an approach in software development that utilizes cloud computing to its fullest due to its use of an open source software stack to deploy applications as microservices.[1][2] Typically, cloud native applications are built as a set of microservices that run in Docker containers, orchestrated in Kubernetes and managed and deployed using DevOps and Git Ops workflows.[3] The advantage of using Docker containers is the ability to package all software needed to execute into one executable package. The container runs in a virtualized environment, which isolates the contained application from its environment.
Cloud native technologies empower organizations to build and run scalable applications in modern, dynamic environments such as public, private, and hybrid clouds. Containers, service meshes, microservices, immutable infrastructure, and declarative APIs exemplify this approach.
PS > docker-composeps 指定されたパスが見つかりません。 Name Command State Ports ---------------------------------------------------------------------------------------- docker_compose_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp docker_compose_web_1 /bin/sh -cwhilesleep100 ... Up 0.0.0.0:5000->5000/tcp PS > docker-compose images 指定されたパスが見つかりません。 Container Repository Tag Image Id Size ----------------------------------------------------------------------------- docker_compose_redis_1 redis alpine a49ff3e0d85f 27.9 MB docker_compose_web_1 docker_compose_web latest 76509309325d 203 MB PS > docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0251a181bf08 docker_compose_web "/bin/sh -c 'while s…" About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp docker_compose_web_1 189be0953add redis:alpine "docker-entrypoint.s…"6 minutes ago Up About a minute 6379/tcp docker_compose_redis_1 PS > docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE docker_compose_web latest 76509309325d 6 minutes ago 213MB <none> <none> f5dbdf087e9b 6 minutes ago 213MB <none> <none> 5b6b84fd1be8 6 minutes ago 213MB <none> <none> c842dd8db35b 6 minutes ago 202MB <none> <none> a1924e4016d1 6 minutes ago 202MB <none> <none> bd8c16c6f245 7 minutes ago 98.4MB <none> <none> 55c33e5cf06c 7 minutes ago 98.4MB <none> <none> c04b6508484b 7 minutes ago 98.4MB redis alpine a49ff3e0d85f 3 weeks ago 29.3MB python 3.7-alpine8922d588eec6 4 weeks ago 98.4MB