[2] DOCKER – podstawy

11 maja 2020 Wyłączono przez Adam [zicherka] Nogły

Teraz pokaże podstawy podstaw DOCKER’a.

Uruchom PowerShell lub linie poleceń (zalecam PowerShell).

[1] Pobierz obraz Windowsa umieszczony w Kontenerze. Sprawdź listę obrazów, uruchom polecenie ECHO w kontenerze.

docker pull mcr.microsoft.com/windows/servercore:ltsc2016

docker images

docker run mcr.microsoft.com/windows/servercore:ltsc2016 powershell -c "echo 'Witaj w świecie kontenerow Windows MFS!!!!'"
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

# pobieramy kontener Windows Server Core
PS C:\Users\Administrator> docker pull mcr.microsoft.com/windows/servercore:ltsc2016
ltsc2016: Pulling from windows/servercore

Digest: sha256:6611aae4ad3de2eb6db8f9893dad4aa04282ec47e68a6e7161325e1de2cfe5eb
Status: Image is up to date for mcr.microsoft.com/windows/servercore:ltsc2016
# lista dostępnych kontenerow na lokalnym serwerze
PS C:\Users\Administrator> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mcr.microsoft.com/windows/servercore ltsc2016 9f784c34a3f0 12 days ago 11.2 GB
# uruchamiamy polecenie ECHO w kontenerze
PS C:\Users\Administrator> docker run mcr.microsoft.com/windows/servercore:ltsc2016 powershell -c "echo 'Witamy w Windows Container World WTF!'"
Witamy w Windows Container World WTF!
PS C:\Users\Administrator>

[2] Podłączamy się do interaktywnej sesji w kontenerze z parametrami [i] oraz [t]. Jeśli opuścisz sesję w kontenerze, to proces, który pracuje w nim się zakończy.

docker run -i -t mcr.microsoft.com/windows/servercore:ltsc2016

systeminfo

exit
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

# uruchamiamy sesję z servercore
PS C:\Users\Administrator> docker run -i -t mcr.microsoft.com/windows/servercore:ltsc2016

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

# komendy wydawane w servercore
C:\>systeminfo

Host Name:                 4629D7422198
OS Name:                   Microsoft Windows Server 2016 Standard Evaluation
OS Version:                10.0.14393 N/A Build 14393
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Server
OS Build Type:             Multiprocessor Free
Registered Owner:          N/A
Registered Organization:   N/A
Product ID:                00377-90000-00001-AA564
Original Install Date:     5/6/2020, 12:41:23 AM
System Boot Time:          5/16/2020, 9:07:41 PM
System Manufacturer:       innotek GmbH
System Model:              VirtualBox
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~3696 Mhz
BIOS Version:              innotek GmbH VirtualBox, 12/1/2006
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb
Total Physical Memory:     4,096 MB
Available Physical Memory: 2,468 MB
Virtual Memory: Max Size:  5,504 MB
Virtual Memory: Available: 3,857 MB
Virtual Memory: In Use:    1,647 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              N/A
Hotfix(s):                 3 Hotfix(s) Installed.
                           [01]: KB4132216
                           [02]: KB4550994
                           [03]: KB4556813
Network Card(s):           N/A
Hyper-V Requirements:      VM Monitor Mode Extensions: Yes
                           Virtualization Enabled In Firmware: Yes
                           Second Level Address Translation: No
                           Data Execution Prevention Available: Yes

# wychodzimy z servercore i wracamy do PowerShell'a
C:\>exit
PS C:\Users\Administrator> # jesteśmy w PowerShell'u

[3] Jeśli chcesz wyjść z kontenera, ale zostawić aktywną sesję w nim pracującą, naciśnij [CTRL]+[p] oraz [Ctrl]+[q].

docker run -it mcr.microsoft.com/windows/servercore:ltsc2016
docker ps

docker attach [ID sesji]

hostname

docker kill [ID sesji]

docker ps
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> docker run -it mcr.microsoft.com/windows/servercore:ltsc2016

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\> # Ctrl=p, Ctrl+q

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>
PS C:\Users\Administrator> docker ps
CONTAINER ID        IMAGE                                           COMMAND                    CREATED              STATUS              PORTS
             NAMES
c7e8c688303d        mcr.microsoft.com/windows/servercore:ltsc2016   "c:\\windows\\system..."   About a minute ago   Up About a minute
             dreamy_visvesvaraya
PS C:\Users\Administrator> docker attach c7e8c688303d

C:\>hostname
c7e8c688303d

C:\> # Ctrl=p, Ctrl+q
PS C:\Users\Administrator> docker kill c7e8c688303d
c7e8c688303d
PS C:\Users\Administrator> docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
PS C:\Users\Administrator>