Docker Basics - docs.adfinis-sygroup.ch · Check your docker version docker version Check the...

Post on 21-Oct-2019

49 views 1 download

Transcript of Docker Basics - docs.adfinis-sygroup.ch · Check your docker version docker version Check the...

DockerBasics

Besmart.Thinkopensource.

Whatarecontainers?

Technicallyspeakingisolateduser-spaceprocesses

a.k.a.OS-levelvirtualization

ProcesstreeisolationFilesystemisolationNetworkisolation

DockerLinuxInterfaces

Goalsofcontainerization

OS-levelvirtualizationWhichsolutionsareavailable?

DockerrktLXCSolarisZonesFreeBSDjail

What'sthedifferencetoVMs?

Containersare

externallymanagednochangesduringruntimepersistenceisoptional

DockerBasics

DockerLifecycle

DockerInstallationhttps://docs.docker.com/engine/installation/

Firststeps

YourfirstcommandsCheckyourdockerversion

dockerversion

Checktheavailabledockeroptions

docker

Yourfirsthello-worldcontainer

dockerrunhello-world

Thispullstheimagehello-world:latestifitisn'tfoundlocally

Runcommandsinacontainerecho"helloworld"

dockerrundebianecho"helloworld"

interactiveshell

dockerrun-itdebianbash#cat/etc/debian_version

BasicDockerCommands

ImagemanagementSearchimagefooonDockerHub

dockersearchfoo

Downloadimagebar

dockerpullbar

Listlocalimages

dockerimages

Deleteimagebazlocally

dockerrmibaz

ImagetagsDownloadimagefoowithtagbar

dockerpullfoo:bar

Deleteimagefoowithtagbarlocally

dockerrmifoo:bar

Rename/retaganimage

dockertagexampleexample:stable

ImagerepositoriesDownloadtheimagebarfromtherepositoryfoo

dockerpullfoo/bar

Pullanimagefromtheregistryexample.com

dockerpullexample.com/foo/bar

Pushanimagetotheregistryexample.com

dockerpushexample.com/foo/bar

ContainermanagementStartacontainerfromtheimagefoo

dockerrunfoo

Startacontainerinthebackground

dockerrun-dfoo

Showrunningcontainers

dockerps

Showlogsfromacontainer

dockerlogs-f$CONTAINER_ID

ContainermanagementShowprocessesrunninginacontainer

dockertop$CONTAINER_ID

Stoparunningcontainer

dockerstop$CONTAINER_ID

Killarunningcontainer

dockerkill$CONTAINER_ID

Deleteacontainer

dockerrm$CONTAINER_ID

ExposedportmanagementExposeacontainerportonthehost

dockerrun-p8080:80nginx

Exposeallconfiguredportsonrandomportsonthehost

dockerrun-Pnginx

Showexposedportsofacontainer

dockerport$CONTAINER_ID

InteractiveshellsincontainersRunainteractiveshellinacontainer

dockerrun-itfoo/bin/bash

Startainteractiveshellinarunningcontainer

dockerexec-it$CONTAINER_ID/bin/bash

AdvancedDockercommands

NameacontainerTooverridetheautomaticallygeneratednamesyoucanspecifyanameontheCLI

dockerrun--namenginx_proxynginx

DeletecontaineronexitTheoption --rm deletesthecontaineronexit

dockerrun--rmcentosyumlistinstalled