Szybkie wprowadzenie do Dockera.
Dodajemy do systemu repozytorium Docker:
1 |
# vim /etc/yum.repos.d/docker.repo |
O zawartości:
1 2 3 4 5 6 |
[dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg |
Aktualizacja systemu
1 |
# yum -y update |
Instalacja silnika dockera
1 |
# yum -y install docker-engine |
Włączenie autostartu dockera
1 |
# systemctl enable docker |
Start serwisu Dockera
1 |
# systemctl start docker |
Sprawdzenie wersji
1 |
# docker -v |
Po instalacji docker dodaje swój wirtualny interfejs sieciowy
1 2 3 4 5 6 7 8 9 |
# ifconfig docker0 docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0 inet6 fe80::42:85ff:fe2b:8534 prefixlen 64 scopeid 0x20<link> ether 02:42:85:2b:85:34 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3 bytes 258 (258.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 |
Sprawdzamy jakie mamy zainstalowane obrazy w dockerze
1 2 |
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE |
Czyli jak na razie nie mamy żadnych obrazów.
Szukamy obrazu np. Centosa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# docker search centos NAME DESCRIPTION STARS OFFICIAL AUTOMATED centos The official build of CentOS. 5438 [OK] ansible/centos7-ansible Ansible on Centos7 121 [OK] jdeathe/centos-ssh CentOS-6 6.10 x86_64 / CentOS-7 7.6.1810 x... 110 [OK] consol/centos-xfce-vnc Centos container with "headless" VNC sessi... 91 [OK] centos/mysql-57-centos7 MySQL 5.7 SQL database server 57 imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 57 [OK] tutum/centos Simple CentOS docker image with SSH access 44 centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relationa... 38 kinogmt/centos-ssh CentOS with SSH 27 [OK] pivotaldata/centos-gpdb-dev CentOS image for GPDB development. Tag nam... 10 nathonfowlie/centos-jre Latest CentOS image with the JRE pre-insta... 8 [OK] drecom/centos-ruby centos ruby 6 [OK] mamohr/centos-java Oracle Java 8 Docker image based on Centos 7 3 [OK] darksheer/centos Base Centos Image -- Updated hourly 3 [OK] pivotaldata/centos Base centos, freshened up a little with a ... 3 pivotaldata/centos-mingw Using the mingw toolchain to cross-compile... 2 miko2u/centos6 CentOS6 日本語環境 2 [OK] pivotaldata/centos-gcc-toolchain CentOS with a toolchain, but unaffiliated ... 2 indigo/centos-maven Vanilla CentOS 7 with Oracle Java Developm... 1 [OK] blacklabelops/centos CentOS Base Image! Built and Updates Daily! 1 [OK] mcnaughton/centos-base centos base image 1 [OK] pivotaldata/centos7-dev CentosOS 7 image for GPDB development 0 fortinj66/centos7-s2i-nodejs based off of ryanj/centos7-s2i-nodejs. Bi... 0 smartentry/centos centos with smartentry 0 [OK] pivotaldata/centos6.8-dev CentosOS 6.8 image for GPDB development 0 |
Szukamy apacha:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# docker search apache NAME DESCRIPTION STARS OFFICIAL AUTOMATED httpd The Apache HTTP Server Project 2541 [OK] tomcat Apache Tomcat is an open source implementa... 2446 [OK] cassandra Apache Cassandra is an open-source distrib... 1002 [OK] maven Apache Maven is a software project managem... 885 [OK] solr Solr is the popular, blazing-fast, open so... 672 [OK] eboraas/apache-php PHP on Apache (with SSL/TLS support), buil... 142 [OK] apache/nifi Unofficial convenience binaries and Docker... 131 [OK] apache/zeppelin Apache Zeppelin 92 [OK] eboraas/apache Apache (with SSL/TLS support), built on De... 91 [OK] nimmis/apache-php5 This is docker images of Ubuntu 14.04 LTS ... 61 [OK] apacheignite/ignite Apache Ignite In-Memory docker image. 54 [OK] bitnami/apache Bitnami Apache Docker Image 54 [OK] linuxserver/apache An Apache container, brought to you by Lin... 22 apache/nutch Apache Nutch 19 [OK] antage/apache2-php5 Docker image for running Apache 2.x with P... 14 [OK] webdevops/apache Apache container 12 [OK] apachepulsar/pulsar Apache Pulsar - Distributed pub/sub messag... 9 lephare/apache Apache container 5 [OK] firespring/apache2-php Based on Ubuntu 16.04. Contains php and a ... 4 [OK] newdeveloper/apache-php-composer apache-php-composer 3 newdeveloper/apache-php apache-php7.2 3 secoresearch/apache-varnish Apache+PHP+Varnish5.0 2 [OK] oberonamsterdam/apache24-fpm Default Oberon apache setup using PHP-FPM,... 1 [OK] jelastic/apachephp An image of the Apache PHP application ser... 0 foobox/apache Apache2 Webserver 0 [OK] |
Szukamy Apache, który występuje w niektórych systemach pod nazwą http (np. RedHat):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# docker search httpd NAME DESCRIPTION STARS OFFICIAL AUTOMATED httpd The Apache HTTP Server Project 2541 [OK] centos/httpd 23 [OK] centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or b... 22 armhf/httpd The Apache HTTP Server Project 8 polinux/httpd-php Apache with PHP in Docker (Supervisor, Cen... 3 [OK] salim1983hoop/httpd24 Dockerfile running apache config 2 [OK] lolhens/httpd Apache httpd 2 Server 2 [OK] rgielen/httpd-image-simple Docker image for simple Apache httpd based... 1 [OK] lead4good/httpd-fpm httpd server which connects via fcgi proxy... 1 [OK] itsziget/httpd24 Extended HTTPD Docker image based on the o... 0 [OK] dockerpinata/httpd 0 interlutions/httpd httpd docker image with debian-based confi... 0 [OK] solsson/httpd-openidc mod_auth_openidc on official httpd image, ... 0 [OK] izdock/httpd Production ready Apache HTTPD Web Server +... 0 amd64/httpd The Apache HTTP Server Project 0 manageiq/httpd_configmap_generator Httpd Configmap Generator 0 [OK] appertly/httpd Customized Apache HTTPD that uses a PHP-FP... 0 [OK] buzzardev/httpd Based on the official httpd image 0 [OK] publici/httpd httpd:latest 0 [OK] ppc64le/httpd The Apache HTTP Server Project 0 manasip/httpd 0 tugboatqa/httpd The Apache HTTP Server Project 0 alvistack/httpd Docker Image Packaging for Apache 0 [OK] manageiq/httpd Container with httpd, built on CentOS for ... 0 [OK] trollin/httpd 0 |
“Pociągnijmy” teraz obraz testowej aplikacji hello-world:
1 2 3 4 5 6 |
# docker pull hello-world Using default tag: latest latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8 Status: Downloaded newer image for hello-world:latest |
Sprawdzamy jakie mamy obrazy w dockerze:
1 2 3 |
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest fce289e99eb9 6 months ago 1.84kB |
Uruchamiamy naszą testową aplikację:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# docker run hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ |
Uruchomienie tej samej aplikacji podając ID jej obrazu:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# docker run 4ab4c602aa5e Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ |
Domyślnie ciągniemy najnowszą wersję wybranego programu:
1 2 3 4 5 6 |
# docker pull centos Using default tag: latest latest: Pulling from library/centos 8ba884070f61: Pull complete Digest: sha256:a799dd8a2ded4a83484bbae769d97655392b3f86533ceb7dd96bbac929809f3c Status: Downloaded newer image for centos:latest |
Możemy też podać jak a wersje chcemy:
1 2 3 4 5 |
# docker pull centos:centos6 centos6: Pulling from library/centos 9bfcefca2b8d: Pull complete Digest: sha256:935c45b2e2c4f01aa5a6ff8625632390c7685835a8dfcfdd50790aabc9c24d11 Status: Downloaded newer image for centos:centos6 |
Wyszukanie NGINX:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 11654 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy for docker c... 1623 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable ... 724 [OK] bitnami/nginx Bitnami nginx Docker Image 68 [OK] linuxserver/nginx An Nginx container, brought to you by Linu... 65 tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rt... 48 [OK] nginx/nginx-ingress NGINX Ingress Controller for Kubernetes 20 nginxdemos/hello NGINX webserver that serves a simple page ... 17 [OK] schmunk42/nginx-redirect A very simple container to redirect HTTP t... 17 [OK] jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 16 [OK] crunchgeek/nginx-pagespeed Nginx with PageSpeed + GEO IP + VTS + more... 13 blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 12 [OK] centos/nginx-18-centos7 Platform for running nginx 1.8 or building... 11 centos/nginx-112-centos7 Platform for running nginx 1.12 or buildin... 9 webdevops/nginx Nginx container 8 [OK] nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 7 sophos/nginx-vts-exporter Simple server that scrapes Nginx vts stats... 5 [OK] nginx/nginx-prometheus-exporter NGINX Prometheus Exporter 4 1science/nginx Nginx Docker images that include Consul Te... 4 [OK] mailu/nginx Mailu nginx frontend 3 [OK] travix/nginx NGinx reverse proxy 2 [OK] pebbletech/nginx-proxy nginx-proxy sets up a container running ng... 2 [OK] centos/nginx-110-centos7 Platform for running nginx 1.10 or buildin... 0 wodby/nginx Generic nginx 0 [OK] ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 0 [OK] |
Instalacja obrazu NGINX:
1 2 3 4 5 6 7 8 |
# docker pull nginx Using default tag: latest latest: Pulling from library/nginx fc7181108d40: Pull complete d2e987ca2267: Pull complete 0b760b431b11: Pull complete Digest: sha256:96fb261b66270b900ea5a2c17a26abbfabe95506e73c3a3c65869a6dbe83223a Status: Downloaded newer image for nginx:latest |
Lista zainstalowanych obrazów:
1 2 3 4 5 6 |
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest f68d6e55e065 6 days ago 109MB centos centos6 d0957ffdf8a2 3 months ago 194MB centos latest 9f38484d220f 3 months ago 202MB hello-world latest fce289e99eb9 6 months ago 1.84kB |
Sprawdzenie konfiguracji jakiegoś pakietu, np. nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# docker inspect nginx [ { "Id": "sha256:f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc", "RepoTags": [ "nginx:latest" ], "RepoDigests": [ "nginx@sha256:96fb261b66270b900ea5a2c17a26abbfabe95506e73c3a3c65869a6dbe83223a" ], "Parent": "", "Comment": "", "Created": "2019-07-01T21:25:40.051159139Z", "Container": "2aa9b07987cb2b14da48fc2c46389920c877d8d2992978b30c08766b0e024611", "ContainerConfig": { "Hostname": "2aa9b07987cb", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "80/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION=1.17.1", "NJS_VERSION=0.3.3", "PKG_RELEASE=1~stretch" ], "Cmd": [ "/bin/sh", "-c", "#(nop) ", "CMD [\"nginx\" \"-g\" \"daemon off;\"]" ], "ArgsEscaped": true, "Image": "sha256:b3589c805dd193e4dc7305c2f550112d1c624d5917df39743cbc6edfe603de02", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": { "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>" }, "StopSignal": "SIGTERM" }, "DockerVersion": "18.06.1-ce", "Author": "", "Config": { "Hostname": "", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "80/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION=1.17.1", "NJS_VERSION=0.3.3", "PKG_RELEASE=1~stretch" ], "Cmd": [ "nginx", "-g", "daemon off;" ], "ArgsEscaped": true, "Image": "sha256:b3589c805dd193e4dc7305c2f550112d1c624d5917df39743cbc6edfe603de02", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": { "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>" }, "StopSignal": "SIGTERM" }, "Architecture": "amd64", "Os": "linux", "Size": 109337279, "VirtualSize": 109337279, "GraphDriver": { "Data": { "RootDir": "/var/lib/docker/overlay/363abe11583d2e64b23c55b9433817680825b21afbe45d6e395b77d39bde492c/root" }, "Name": "overlay" }, "RootFS": { "Type": "layers", "Layers": [ "sha256:cf5b3c6798f77b1f78bf4e297b27cfa5b6caa982f04caeb5de7d13c255fd7a1e", "sha256:197c666de9dd65f1c350e2c44628c5d530f366c9edf0197373f8603cf9af9e50", "sha256:d2f0b6dea592c39bfc4f06a1f6502d58a2fa6d9e6b6cf1aaf0d458d5d61d4515" ] } } ] |
Rozważmy przykład prezentujący sposób działania dockera:
1 2 3 4 5 6 7 8 9 10 11 12 |
# docker pull docker/whalesay Using default tag: latest latest: Pulling from docker/whalesay e190868d63f8: Pull complete 909cd34c6fd7: Pull complete 0b9bfabab7c1: Pull complete a3ed95caeb02: Pull complete 00bf65475aba: Pull complete c57b6bcc83e3: Pull complete 8978f6879e2f: Pull complete 8eed3712d2cf: Pull complete Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b |
Uruchamiamy teraz whalesay:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# docker run docker/whalesay cowsay hello _______ < hello > ------- \ \ \ ## . ## ## ## == ## ## ## ## === /""""""""""""""""___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\______/ |
Inny parametr:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# docker run docker/whalesay cowsay IAMDOCKER ___________ < IAMDOCKER > ----------- \ \ \ ## . ## ## ## == ## ## ## ## === /""""""""""""""""___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\______/ |
Lista procesów aktualnie uruchomionych w dockerze:
1 2 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Lista kiedykolwiek uruchomionych procesów w dockerze:
1 2 3 4 5 6 |
# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1c1a43d57700 docker/whalesay "cowsay IAMDOCKER" About a minute ago Exited (0) About a minute ago focused_babbage 6f495d49c862 docker/whalesay "cowsay hello" About a minute ago Exited (0) About a minute ago elated_nightingale be6855d22544 fce289e99eb9 "/hello" 13 minutes ago Exited (0) 13 minutes ago distracted_liskov 9d0a8f9735e7 hello-world:latest "/hello" 14 minutes ago Exited (0) 14 minutes ago practical_minsky |
Uruchomienie Centosa w kontenerze w trybie interaktywnym łącząc się z terminalem i uruchamiąc komendę /bin/bash:
1 2 3 |
# docker run -it centos:latest /bin/bash [root@4c05ae7c9594 /]# whoami root |
Jeżeli teraz z poziomu systemu macierzystego odpalimy w innym terminalu listę aktywnych procesów to Centos się nam wyświetli:
1 2 3 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4c72e5213cc1 centos:latest "/bin/bash" 53 seconds ago Up 52 seconds nostalgic_mclean |
Na liście kiedykolwiek uruchomionych procesów w dockerze centos jest wyświetlony jak proces aktualnie uruchomiony:
1 2 3 4 5 6 7 8 |
# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4c72e5213cc1 centos:latest "/bin/bash" About a minute ago Up About a minute nostalgic_mclean 4c05ae7c9594 centos:latest "/bin/bash" 4 minutes ago Exited (0) 3 minutes ago friendly_jennings 1c1a43d57700 docker/whalesay "cowsay IAMDOCKER" 6 minutes ago Exited (0) 6 minutes ago focused_babbage 6f495d49c862 docker/whalesay "cowsay hello" 7 minutes ago Exited (0) 7 minutes ago elated_nightingale be6855d22544 fce289e99eb9 "/hello" 18 minutes ago Exited (0) 18 minutes ago distracted_liskov 9d0a8f9735e7 hello-world:latest "/hello" 20 minutes ago Exited (0) 20 minutes ago practical_minsky |
Po wyłączeniu centos w dockerze:
1 2 |
[root@4c72e5213cc1 /]# exit exit |
W systemie macierzystem proces centos ma teraz status “Exited”
1 2 3 4 5 6 7 8 |
# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4c72e5213cc1 centos:latest "/bin/bash" 3 minutes ago Exited (0) 35 seconds ago nostalgic_mclean 4c05ae7c9594 centos:latest "/bin/bash" 5 minutes ago Exited (0) 5 minutes ago friendly_jennings 1c1a43d57700 docker/whalesay "cowsay IAMDOCKER" 7 minutes ago Exited (0) 7 minutes ago focused_babbage 6f495d49c862 docker/whalesay "cowsay hello" 8 minutes ago Exited (0) 8 minutes ago elated_nightingale be6855d22544 fce289e99eb9 "/hello" 20 minutes ago Exited (0) 20 minutes ago distracted_liskov 9d0a8f9735e7 hello-world:latest "/hello" 21 minutes ago Exited (0) 21 minutes ago practical_minsky |
Uruchommy teraz Centosa w dockerze w tle (-d detached):
1 2 |
# docker run -d centos /bin/bash 79ada7655abbce4df040e14445b7d101c92c633561c98d54bd41ecdd32a1a71a |
Gdzie: "79ada7655abbce4df040e14445b7d101c92c633561c98d54bd41ecdd32a1a71a"
to identyfikator procesu uruchomionego w dockerze.
Na liście kiedykolwiek uruchomionych procesów w dockerze centos widnieje ze statusem “Exited”
1 2 3 4 5 6 7 8 9 |
# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 79ada7655abb centos "/bin/bash" About a minute ago Exited (0) About a minute ago quirky_northcutt 4c72e5213cc1 centos:latest "/bin/bash" 6 minutes ago Exited (0) 3 minutes ago nostalgic_mclean 4c05ae7c9594 centos:latest "/bin/bash" 8 minutes ago Exited (0) 8 minutes ago friendly_jennings 1c1a43d57700 docker/whalesay "cowsay IAMDOCKER" 11 minutes ago Exited (0) 11 minutes ago focused_babbage 6f495d49c862 docker/whalesay "cowsay hello" 11 minutes ago Exited (0) 11 minutes ago elated_nightingale be6855d22544 fce289e99eb9 "/hello" 23 minutes ago Exited (0) 23 minutes ago distracted_liskov 9d0a8f9735e7 hello-world:latest "/hello" 24 minutes ago Exited (0) 24 minutes ago practical_minsky |
Lista aktualnie działających procesów:
1 2 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Uruchommy teraz serwer nginx w tle w dockerze:
1 2 |
# docker run -d nginx:latest e0c41400da88a217059542c116c3101177dc291be870a57c8ccd4f64f79eee6d |
Aktywne procesy:
1 2 3 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e0c41400da88 nginx:latest "nginx -g 'daemon ..." 2 minutes ago Up 2 minutes 80/tcp xenodochial_keller |
Przeprowadźmy teraz inspekcję serwera uruchomionego w kontenerrze:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# docker inspect xenodochial_keller [ { "Id": "e0c41400da88a217059542c116c3101177dc291be870a57c8ccd4f64f79eee6d", "Created": "2019-07-08T16:48:48.737320961Z", "Path": "nginx", "Args": [ "-g", "daemon off;" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 7472, "ExitCode": 0, "Error": "", "StartedAt": "2019-07-08T16:48:49.049733192Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc", "ResolvConfPath": "/var/lib/docker/containers/e0c41400da88a217059542c116c3101177dc291be870a57c8ccd4f64f79eee6d/resolv.conf", "HostnamePath": "/var/lib/docker/containers/e0c41400da88a217059542c116c3101177dc291be870a57c8ccd4f64f79eee6d/hostname", "HostsPath": "/var/lib/docker/containers/e0c41400da88a217059542c116c3101177dc291be870a57c8ccd4f64f79eee6d/hosts", "LogPath": "/var/lib/docker/containers/e0c41400da88a217059542c116c3101177dc291be870a57c8ccd4f64f79eee6d/e0c41400da88a217059542c116c3101177dc291be870a57c8ccd4f64f79eee6d-json.log", "Name": "/xenodochial_keller", "RestartCount": 0, "Driver": "overlay", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": null, "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": {}, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": null, "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": -1, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0 }, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay/363abe11583d2e64b23c55b9433817680825b21afbe45d6e395b77d39bde492c/root", "MergedDir": "/var/lib/docker/overlay/3a72efd85c9920b5ad6bbf67d8c62d5a1a2fe610fde3d57a08e262bfd76e9741/merged", "UpperDir": "/var/lib/docker/overlay/3a72efd85c9920b5ad6bbf67d8c62d5a1a2fe610fde3d57a08e262bfd76e9741/upper", "WorkDir": "/var/lib/docker/overlay/3a72efd85c9920b5ad6bbf67d8c62d5a1a2fe610fde3d57a08e262bfd76e9741/work" }, "Name": "overlay" }, "Mounts": [], "Config": { "Hostname": "e0c41400da88", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "80/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION=1.17.1", "NJS_VERSION=0.3.3", "PKG_RELEASE=1~stretch" ], "Cmd": [ "nginx", "-g", "daemon off;" ], "ArgsEscaped": true, "Image": "nginx:latest", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": { "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>" }, "StopSignal": "SIGTERM" }, "NetworkSettings": { "Bridge": "", "SandboxID": "67e3b1e38acce02557a9794d1e6f4ef9fc47226e3c41aa8fecaa9c5b5adbe0ea", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "80/tcp": null }, "SandboxKey": "/var/run/docker/netns/67e3b1e38acc", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "ad55048bd132076c8446ec2adb5245bc2227e3f3fb706d58895fb48488c64619", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "c169d23db27958a75c87983b481738ebf10e0b39c7b8bed0d27a7e8e5efc2974", "EndpointID": "ad55048bd132076c8446ec2adb5245bc2227e3f3fb706d58895fb48488c64619", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02" } } } } |
Serwer nginx ma nadany adres IP 172.17.0.2, który da się zapingować:
1 2 3 4 5 6 7 8 9 |
# ping 172.17.0.2 PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data. 64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.105 ms 64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.042 ms 64 bytes from 172.17.0.2: icmp_seq=3 ttl=64 time=0.042 ms ^C --- 172.17.0.2 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2000ms rtt min/avg/max/mdev = 0.042/0.063/0.105/0.029 ms |
Sprawdźmy teraz czy można wejść na stronę serwowaną przez nginxa, uruchomionego w kontenerze:
1 |
# elinks 172.17.0.2 |
Aplikację w kontenerze możem teraz wyłączyć
1 2 |
# docker stop xenodochial_keller xenodochial_keller |
1 2 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Uruchamianie aplikacji w dockerze z nadaniem własnej nazwy:
1 2 3 4 5 6 |
# docker run -d --name=MojaStrona1 nginx:latest 5d293e8321166a3928647f2e57760d01270e24e8ab493330c38b9055ea7b0141 # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5d293e832116 nginx:latest "nginx -g 'daemon ..." About a minute ago Up About a minute 80/tcp MojaStrona1 |
Inspekcję możemy przeprowadzać podając jako parametr nazwę lub id procesu dockera:
1 2 |
# docker inspect MojaStrona1 # docker inspect 5d293e832116 |
Uruchamianie kolejnego serwera nginx w dockerze spowouje, że będzie on miał inny adres IP:
1 2 |
# docker run -d --name=MojaStrona2 nginx:latest a21191189c22d26cf10c1cfe2a88f718f9e12aecb69f17446a4ebea91eadf902 |
Inspekcja:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# docker inspect MojaStrona2 [ { "Id": "a21191189c22d26cf10c1cfe2a88f718f9e12aecb69f17446a4ebea91eadf902", "Created": "2019-07-08T17:01:03.544451643Z", "Path": "nginx", "Args": [ "-g", "daemon off;" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 7871, "ExitCode": 0, "Error": "", "StartedAt": "2019-07-08T17:01:03.861343231Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:f68d6e55e06520f152403e6d96d0de5c9790a89b4cfc99f4626f68146fa1dbdc", "ResolvConfPath": "/var/lib/docker/containers/a21191189c22d26cf10c1cfe2a88f718f9e12aecb69f17446a4ebea91eadf902/resolv.conf", "HostnamePath": "/var/lib/docker/containers/a21191189c22d26cf10c1cfe2a88f718f9e12aecb69f17446a4ebea91eadf902/hostname", "HostsPath": "/var/lib/docker/containers/a21191189c22d26cf10c1cfe2a88f718f9e12aecb69f17446a4ebea91eadf902/hosts", "LogPath": "/var/lib/docker/containers/a21191189c22d26cf10c1cfe2a88f718f9e12aecb69f17446a4ebea91eadf902/a21191189c22d26cf10c1cfe2a88f718f9e12aecb69f17446a4ebea91eadf902-json.log", "Name": "/MojaStrona2", "RestartCount": 0, "Driver": "overlay", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": null, "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": {}, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": null, "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": -1, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0 }, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay/363abe11583d2e64b23c55b9433817680825b21afbe45d6e395b77d39bde492c/root", "MergedDir": "/var/lib/docker/overlay/6906f8e5c4b5c89d14a025329b6a41a72bddeb236670b5f389ef60970e73104c/merged", "UpperDir": "/var/lib/docker/overlay/6906f8e5c4b5c89d14a025329b6a41a72bddeb236670b5f389ef60970e73104c/upper", "WorkDir": "/var/lib/docker/overlay/6906f8e5c4b5c89d14a025329b6a41a72bddeb236670b5f389ef60970e73104c/work" }, "Name": "overlay" }, "Mounts": [], "Config": { "Hostname": "a21191189c22", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "80/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION=1.17.1", "NJS_VERSION=0.3.3", "PKG_RELEASE=1~stretch" ], "Cmd": [ "nginx", "-g", "daemon off;" ], "ArgsEscaped": true, "Image": "nginx:latest", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": { "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>" }, "StopSignal": "SIGTERM" }, "NetworkSettings": { "Bridge": "", "SandboxID": "71e6e72efddc531fae23de8a48265393224e15210f2c143f7faf73303ec7b813", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "80/tcp": null }, "SandboxKey": "/var/run/docker/netns/71e6e72efddc", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "69d48a801ff0a643b9026fbf507765de1e328b4944af5163f16d0c6c8d6c6d3e", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.3", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:03", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "c169d23db27958a75c87983b481738ebf10e0b39c7b8bed0d27a7e8e5efc2974", "EndpointID": "69d48a801ff0a643b9026fbf507765de1e328b4944af5163f16d0c6c8d6c6d3e", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.3", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:03" } } } } ] |
Restart kontenera MojaStrona1:
1 2 |
# docker restart MojaStrona1 MojaStrona1 |
Zatrzymanie procesu obsługującego stronę 1:
1 2 3 4 5 6 |
# docker stop MojaStrona1 MojaStrona1 # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a21191189c22 nginx:latest "nginx -g 'daemon ..." 6 minutes ago Up 6 minutes 80/tcp MojaStrona2 |
Zatrzymanie procesu obsługującego stronę 2:
1 2 3 4 5 |
# docker stop MojaStrona2 MojaStrona2 # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Uruchomienie tych samych procesów w danym kontenerze:
1 2 3 4 5 6 7 8 9 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES # docker start MojaStrona1 MojaStrona1 # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b2e6be9d7caa nginx:latest "nginx -g 'daemon ..." 2 hours ago Up 11 seconds 80/tcp MojaStrona1 |
Uruchomienie komend w danym kontenerze. Tutaj uruchamiamy komendę /bin/bash w kontenerze MojaStrona1:
1 2 3 4 5 6 7 8 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES # docker exec /bin/bash MojaStrona1 EOF # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Podłączenie się do kontenera, na którym wcześniej uruchomiliśmy komendę:
1 2 3 4 |
# docker exec -it MojaStrona1 /bin/bash root@5d293e832116:/# whoami root # docker stop MojaStrona1 |
Uruchomienie i podłączanie się do konkretnego kontenera:
1 2 3 4 5 6 7 8 9 10 |
# docker run -itd --name=mycentos1 centos:latest c43286c91e5c172e38c4b0431b1d3e68a0846c5e210d804ffc9862fe942fa042 # docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c43286c91e5c centos:latest "/bin/bash" 48 seconds ago Up 47 seconds mycentos1 [root@miro ~]# docker ps # docker attach mycentos1 [root@c43286c91e5c /]# exit |
Kontener przestał dzialać po wyjściu:
1 2 |
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Podłączanie do kontenera w taki sposob że po wyjściu kontener działa nadal po wyjściu z niego:
1 2 3 4 5 |
# docker exec -t mycentos6 /bin/bash [root@5f357e0a1a1d /]# ps aux | grep ngnix [root@miro ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5f357e0a1a1d centos:latest "/bin/bash" 4 minutes ago Up 4 minutes mycentos6 |
Wyłączanie manualne
1 2 3 4 |
[root@miro ~]# docker stop mycentos6 mycentos6 [root@miro ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
1 2 3 4 5 |
[root@miro ~]# docker start mycentos6 mycentos6 [root@miro ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5f357e0a1a1d centos:latest "/bin/bash" 8 minutes ago Up 2 seconds mycentos6 |
Zarządzanie image i kontenerami
Usuwanie
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest f68d6e55e065 6 days ago 109MB centos centos6 d0957ffdf8a2 3 months ago 194MB centos latest 9f38484d220f 3 months ago 202MB hello-world latest fce289e99eb9 6 months ago 1.84kB docker/whalesay latest 6b362a9f73eb 4 years ago 247MB # docker rmi centos:centos6 Untagged: centos:centos6 Untagged: centos@sha256:dec8f471302de43f4cfcf82f56d99a5227b5ea1aa6d02fa56344986e1f4610e7 Deleted: sha256:d0957ffdf8a2ea8c8925903862b65a1b6850dbb019f88d45e927d3d5a3fa0c31 Deleted: sha256:af6bf1987c2eb07d73f33836b0d8fd825d7c785273526b077e46780e8b4b2ae9 # docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest f68d6e55e065 6 days ago 109MB centos latest 9f38484d220f 3 months ago 202MB hello-world latest fce289e99eb9 6 months ago 1.84kB docker/whalesay latest 6b362a9f73eb 4 years ago 247MB |
Usuwanie kontenera, który kiedyś był uruchomiony jest trudniejsze
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 1e1148e4cc2c 2 weeks ago 202MB nginx latest 568c4670fa80 3 weeks ago 109MB hello-world latest 4ab4c602aa5e 3 months ago 1.84kB docker/whalesay latest 6b362a9f73eb 3 years ago 247MB # docker rmi hello-world Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container 9d0a8f9735e7 is using its referenced image fce289e99eb9 [root@beauty ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 71e21213ef6e centos:latest "/bin/bash" 15 minutes ago Exited (137) 10 minutes ago mycentos1 a21191189c22 nginx:latest "nginx -g 'daemon ..." 39 minutes ago Exited (0) 32 minutes ago MojaStrona2 5d293e832116 nginx:latest "nginx -g 'daemon ..." 41 minutes ago Exited (0) 13 minutes ago MojaStrona1 e0c41400da88 nginx:latest "nginx -g 'daemon ..." About an hour ago Exited (0) 43 minutes ago xenodochial_keller 79ada7655abb centos "/bin/bash" About an hour ago Exited (0) About an hour ago quirky_northcutt 4c72e5213cc1 centos:latest "/bin/bash" About an hour ago Exited (0) About an hour ago nostalgic_mclean 4c05ae7c9594 centos:latest "/bin/bash" About an hour ago Exited (0) About an hour ago friendly_jennings 1c1a43d57700 docker/whalesay "cowsay IAMDOCKER" About an hour ago Exited (0) About an hour ago focused_babbage 6f495d49c862 docker/whalesay "cowsay hello" About an hour ago Exited (0) About an hour ago elated_nightingale be6855d22544 fce289e99eb9 "/hello" About an hour ago Exited (0) About an hour ago distracted_liskov 9d0a8f9735e7 hello-world:latest "/hello" About an hour ago Exited (0) About an hour ago practical_minsky |
Trzeba wymusić:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# docker rmi -f hello-world Untagged: hello-world:latest Untagged: hello-world@sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8 Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 71e21213ef6e centos:latest "/bin/bash" 16 minutes ago Exited (137) 11 minutes ago mycentos1 a21191189c22 nginx:latest "nginx -g 'daemon ..." 40 minutes ago Exited (0) 33 minutes ago MojaStrona2 5d293e832116 nginx:latest "nginx -g 'daemon ..." 43 minutes ago Exited (0) 14 minutes ago MojaStrona1 e0c41400da88 nginx:latest "nginx -g 'daemon ..." About an hour ago Exited (0) 44 minutes ago xenodochial_keller 79ada7655abb centos "/bin/bash" About an hour ago Exited (0) About an hour ago quirky_northcutt 4c72e5213cc1 centos:latest "/bin/bash" About an hour ago Exited (0) About an hour ago nostalgic_mclean 4c05ae7c9594 centos:latest "/bin/bash" About an hour ago Exited (0) About an hour ago friendly_jennings 1c1a43d57700 docker/whalesay "cowsay IAMDOCKER" About an hour ago Exited (0) About an hour ago focused_babbage 6f495d49c862 docker/whalesay "cowsay hello" About an hour ago Exited (0) About an hour ago elated_nightingale be6855d22544 fce289e99eb9 "/hello" About an hour ago Exited (0) About an hour ago distracted_liskov 9d0a8f9735e7 fce289e99eb9 "/hello" About an hour ago Exited (0) About an hour ago practical_minsky # docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest f68d6e55e065 6 days ago 109MB centos latest 9f38484d220f 3 months ago 202MB docker/whalesay latest 6b362a9f73eb 4 years ago 247MB |
Kontenery, które już nie działają w systemie
1 2 3 4 5 6 7 8 9 10 11 12 |
# docker ps -a -q 71e21213ef6e a21191189c22 5d293e832116 e0c41400da88 79ada7655abb 4c72e5213cc1 4c05ae7c9594 1c1a43d57700 6f495d49c862 be6855d22544 9d0a8f9735e7 |
Usuwanie takich kontenerów
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# docker rm `docker ps -a -q` 71e21213ef6e a21191189c22 5d293e832116 e0c41400da88 79ada7655abb 4c72e5213cc1 4c05ae7c9594 1c1a43d57700 6f495d49c862 be6855d22544 9d0a8f9735e7 # docker ps -a -q # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |