Docker

Docker

Docker, "konteynerleştirme" olarak da bilinen işletim sistemi seviyesinde sanallaştırma sağlayan bir bilgisayar programıdır. İlk sürümü 2013'te yayınlanmıştır. Docker, "konteyner" adı verilen yazılım paketlerini çalıştırmak için kullanılmaktadır. Konteynerler birbirinden izole edilmiş ve bağımsız halde çalışabilmektedir. Tüm konteynerler tek bir işletim sistemi çekirdeği üzerinde çalışır ve bu sayede sanal makinelerden daha hafiftir. Konteynerler "imaj" (image) adı verilen salt-okunur dosya sistemlerinden oluşturulur. [1]

Basit Docker Komutları

docker run

docker run komutu istenen imaj üzerinde yeni bir container oluşturarak belirtilen komutu çalıştırır.

Kullanımı:

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
$ docker run busybox echo hi there!
hi there!

docker run komutu aslında docker create ve docker start komutlarını kapsamaktadır.

docker create komutu ile yeni bir container oluşturulur ve oluşturulan container'ın  id'si döndürülür. Docker start ile başlatılmak istenen container, id'si verilerek istenilen komutla çalıştırılır.

Kullanımı:

docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
docker start [OPTIONS] CONTAINER [CONTAINER...]
$ docker create busybox echo hello,there!
c7507d23cc6570ac1f25ff0e3a3181d927bac2249e33e5bec236ed41c41d22b2
$ docker start 06a6d2a2d4e307cd813b9caf158db84881872d8c8232891e6ff0ef96a33a03bd
06a6d2a2d4e307cd813b9caf158db84881872d8c8232891e6ff0ef96a33a03bd

docker start komutu, -a parametresi kullanılarak çalıştırılırsa, oluşan çıktı görüntülenir.

$ docker start -a 06a6d2a2d4e307cd813b9caf158db84881872d8c8232891e6ff0ef96a33a03bd
hello,there!

docker ps

docker ps komutu ile çalışmakta olan container'ların listesi görüntülenir. -a(ya da --all) parametresi ile hem çalışan hemde durmuş olan container'ların listesi görüntülenir.

Kullanımı:

docker ps [OPTIONS]
$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS         PORTS     NAMES
a005c41dbc06   busybox   "ping caglagokgoz.com"   10 seconds ago   Up 9 seconds             naughty_mayer
$ docker ps -a
CONTAINER ID   IMAGE            COMMAND                  CREATED              STATUS                          PORTS     NAMES
a005c41dbc06   busybox          "ping caglagokgoz.com"   About a minute ago   Exited (0) About a minute ago             naughty_mayer
06a6d2a2d4e3   busybox          "echo hello,there!"      About an hour ago    Exited (0) 48 minutes ago                 relaxed_poitras
c7507d23cc65   busybox          "sh"                     About an hour ago    Exited (0) About an hour ago              exciting_mclaren
65604689bbf6   busybox          "echo hi there!"         About an hour ago    Exited (0) About an hour ago              blissful_hoover
bb739c943305   busybox          "ping caglagokgoz.com"   39 hours ago         Exited (137) 39 hours ago                 nice_nobel
a997aef516bf   postgres:10.15   "docker-entrypoint.s…"   11 days ago          Exited (0) 41 hours ago                   postgresql_db_1

docker logs

docker logs komutu ile istenen container'ın(çalışmakta veya durmuş) log bilgileri görüntülenir.

Kullanımı:

docker logs [OPTIONS] CONTAINER
$ docker logs a005c41dbc06
PING caglagokgoz.com (34.89.36.67): 56 data bytes
64 bytes from 34.89.36.67: seq=0 ttl=54 time=81.244 ms
64 bytes from 34.89.36.67: seq=1 ttl=54 time=82.708 ms
64 bytes from 34.89.36.67: seq=2 ttl=54 time=82.021 ms
64 bytes from 34.89.36.67: seq=3 ttl=54 time=124.538 ms
64 bytes from 34.89.36.67: seq=4 ttl=54 time=84.066 ms
64 bytes from 34.89.36.67: seq=5 ttl=54 time=85.666 ms
64 bytes from 34.89.36.67: seq=6 ttl=54 time=97.808 ms
64 bytes from 34.89.36.67: seq=7 ttl=54 time=215.334 ms
64 bytes from 34.89.36.67: seq=8 ttl=54 time=87.353 ms
64 bytes from 34.89.36.67: seq=9 ttl=54 time=80.855 ms
64 bytes from 34.89.36.67: seq=10 ttl=54 time=80.792 ms
64 bytes from 34.89.36.67: seq=11 ttl=54 time=80.422 ms
64 bytes from 34.89.36.67: seq=12 ttl=54 time=79.394 ms
64 bytes from 34.89.36.67: seq=13 ttl=54 time=154.355 ms
64 bytes from 34.89.36.67: seq=14 ttl=54 time=179.054 ms
64 bytes from 34.89.36.67: seq=15 ttl=54 time=308.482 ms
64 bytes from 34.89.36.67: seq=16 ttl=54 time=232.327 ms
64 bytes from 34.89.36.67: seq=17 ttl=54 time=294.825 ms
64 bytes from 34.89.36.67: seq=18 ttl=54 time=131.459 ms
64 bytes from 34.89.36.67: seq=19 ttl=54 time=80.004 ms
64 bytes from 34.89.36.67: seq=20 ttl=54 time=78.710 ms
64 bytes from 34.89.36.67: seq=21 ttl=54 time=79.480 ms
64 bytes from 34.89.36.67: seq=22 ttl=54 time=79.089 ms
64 bytes from 34.89.36.67: seq=23 ttl=54 time=83.766 ms
64 bytes from 34.89.36.67: seq=24 ttl=54 time=79.464 ms
64 bytes from 34.89.36.67: seq=25 ttl=54 time=80.308 ms
64 bytes from 34.89.36.67: seq=26 ttl=54 time=81.389 ms
64 bytes from 34.89.36.67: seq=27 ttl=54 time=85.925 ms
64 bytes from 34.89.36.67: seq=28 ttl=54 time=81.428 ms
64 bytes from 34.89.36.67: seq=29 ttl=54 time=119.399 ms
64 bytes from 34.89.36.67: seq=30 ttl=54 time=87.533 ms
64 bytes from 34.89.36.67: seq=31 ttl=54 time=86.701 ms
64 bytes from 34.89.36.67: seq=32 ttl=54 time=108.542 ms
64 bytes from 34.89.36.67: seq=33 ttl=54 time=81.498 ms
64 bytes from 34.89.36.67: seq=34 ttl=54 time=87.517 ms
64 bytes from 34.89.36.67: seq=35 ttl=54 time=99.615 ms

--- caglagokgoz.com ping statistics ---
36 packets transmitted, 36 packets received, 0% packet loss
round-trip min/avg/max = 78.710/112.307/308.482 ms