windows安装docker官方说明.docx
《windows安装docker官方说明.docx》由会员分享,可在线阅读,更多相关《windows安装docker官方说明.docx(12页珍藏版)》请在冰点文库上搜索。
![windows安装docker官方说明.docx](https://file1.bingdoc.com/fileroot1/2023-4/28/fe8ad7f3-5c46-4084-9404-96998aa2f094/fe8ad7f3-5c46-4084-9404-96998aa2f0941.gif)
windows安装docker官方说明
Windows
Note:
ThisreleaseofDockerdeprecatestheBoot2DockercommandlineinfavorofDockerMachine.UsetheDockerToolboxtoinstallDockerMachineaswellastheotherDockertools.
YouinstallDockerusingDockerToolbox.DockerToolboxincludesthefollowingDockertools:
∙DockerMachineforrunningthe docker-machine binary
∙DockerEngineforrunningthe docker binary
∙Kitematic,theDockerGUI
∙ashellpreconfiguredforaDockercommand-lineenvironment
∙OracleVMVirtualBox
BecausetheDockerdaemonusesLinux-specifickernelfeatures,youcan’trunDockernativelyinWindows.Instead,youmustuse docker-machine tocreateandattachtoaDockerVMonyourmachine.ThisVMhostsDockerforyouonyourWindowssystem.
ThevirtualmachinerunsalightweightLinuxdistributionmadespecificallytoruntheDockerdaemon.TheVirtualBoxVMrunscompletelyfromRAM,isasmall~24MBdownload,andbootsinapproximately5s.
Requirements
TorunDocker,yourmachinemusthavea64-bitoperatingsystemrunningWindows7orhigher.Additionally,youmustmakesurethatvirtualizationisenabledonyourmachine.Toverifyyourmachinemeetstheserequirements,dothefollowing:
1.RightclicktheWindowsStartMenuandchoose System.
IfyouareusinganunsupportedversionofWindows,youshouldconsiderupgradingyouroperatingsysteminordertotryoutDocker.
2.MakesureyourCPUsupports virtualizationtechnology andvirtualizationsupportisenabledinBIOSandrecognizedbyWindows.
ForWindows8,8.1or10
Choose Start>TaskManager.OnWindows10,clickmoredetails.NavigatetothePerformance tab.Under CPU youshouldseethefollowing:
Ifvirtualizationisnotenabledonyoursystem,followthemanufacturer’sinstructionsforenablingit.
ForWindows7
Runthe Microsoft®Hardware-AssistedVirtualizationDetectionTool andfollowtheon-screeninstructions.
3.VerifyyourWindowsOSis64-bit(x64)
HowyoudothisverificationdependsonyourWindowsversion.Fordetails,seetheWindowsarticle Howtodeterminewhetheracomputerisrunninga32-bitversionor64-bitversionoftheWindowsoperatingsystem.
Note:
IfyouhaveDockerhostsrunningandyoudon’twishtodoaDockerToolboxinstallation,youcaninstallthe docker.exe usingthe unofficial WindowspackagemanagerChocolatey.Forinformationonhowtodothis,see DockerpackageonChocolatey.
Learnthekeyconceptsbeforeinstalling
InaDockerinstallationonLinux,yourmachineisboththelocalhostandtheDockerhost.Innetworking,localhostmeansyourcomputer.TheDockerhostisthemachineonwhichthecontainersrun.
OnatypicalLinuxinstallation,theDockerclient,theDockerdaemon,andanycontainersrundirectlyonyourlocalhost.ThismeansyoucanaddressportsonaDockercontainerusingstandardlocalhostaddressingsuchas localhost:
8000 or0.0.0.0:
8376.
InanWindowsinstallation,the docker daemonisrunninginsideaLinuxvirtualmachine.YouusetheWindowsDockerclienttotalktotheDockerhostVM.YourDockercontainersruninsidethishost.
InWindows,theDockerhostaddressistheaddressoftheLinuxVM.WhenyoustarttheVMwith docker-machine itisassignedanIPaddress.Whenyoustartacontainer,theportsonacontainermaptoportsontheVM.Toseethisinpractice,workthroughtheexercisesonthispage.
Installation
IfyouhaveVirtualBoxrunning,youmustshutitdownbeforerunningtheinstaller.
1.Gotothe DockerToolbox page.
2.Clicktheinstallerlinktodownload.
3.InstallDockerToolboxbydouble-clickingtheinstaller.
Theinstallerlaunchesthe“Setup-DockerToolbox”dialog.
4.Press“Next”toinstallthetoolbox.
Theinstallerpresentsyouwithoptionstocustomizethestandardinstallation.Bydefault,thestandardDockerToolboxinstallation:
oinstallsexecutablesfortheDockertoolsinC:
\ProgramFiles\DockerToolbox
oinstallVirtualBox;orupdatesanyexistinginstallation
oaddsaDockerInc.foldertoyourprogramshortcuts
oupdatesyour PATH environmentvariable
oaddsdesktopiconsfortheDockerQuickstartTerminalandKitematic
Thisinstallationassumesthedefaultsareacceptable.
5.Press“Next”untilyoureachthe“ReadytoInstall”page.
Thesystempromptsyouforyourpassword.
6.Press“Install”tocontinuewiththeinstallation.
Whenitcompletes,theinstallerprovidesyouwithsomeinformationyoucanusetocompletesomecommontasks.
7.Press“Finish”toexit.
RunningaDockerContainer
TorunaDockercontainer,you:
∙createanew(orstartanexisting)Dockervirtualmachine
∙switchyourenvironmenttoyournewVM
∙usethe docker clienttocreate,load,andmanagecontainers
Onceyoucreateamachine,youcanreuseitasoftenasyoulike.LikeanyVirtualBoxVM,itmaintainsitsconfigurationbetweenuses.
Thereareseveralwaystousetheinstalledtools,fromtheDockerQuickstartTerminalor fromyourshell.
UsingtheDockerQuickstartTerminal
1.FindtheDockerQuickstartTerminalicononyourDesktopanddouble-clicktolaunchit.
Theapplication:
oopensaterminalwindow
ocreatesa default VMifitdoesn’texist,andstartstheVMafter
opointstheterminalenvironmenttothisVM
Oncethelaunchcompletes,youcanrun docker commands.
2.Verifyyoursetupsucceededbyrunningthe hello-world container.
3.$dockerrunhello-world
4.Unabletofindimage'hello-world:
latest'locally
5.511136ea3c5a:
Pullcomplete
6.31cbccb51277:
Pullcomplete
7.e45a5af57b00:
Pullcomplete
8.hello-world:
latest:
Theimageyouarepullinghasbeenverified.
9.Important:
imageverificationisatechpreviewfeatureandshouldnotbe
10.reliedontoprovidesecurity.
11.Status:
Downloadednewerimageforhello-world:
latest
12.HellofromDocker.
13.Thismessageshowsthatyourinstallationappearstobeworkingcorrectly.
14.
15.Togeneratethismessage,Dockertookthefollowingsteps:
16.1.TheDockerclientcontactedtheDockerdaemon.
17.2.TheDockerdaemonpulledthe"hello-world"imagefromtheDockerHub.
18.(Assumingitwasnotalreadylocallyavailable.)
19.3.TheDockerdaemoncreatedanewcontainerfromthatimagewhichrunsthe
20.executablethatproducestheoutputyouarecurrentlyreading.
21.4.TheDockerdaemonstreamedthatoutputtotheDockerclient,whichsentit
22.toyourterminal.
23.
24.Totrysomethingmoreambitious,youcanrunanUbuntucontainerwith:
25.$dockerrun-itubuntubash
26.
27.Formoreexamplesandideas,visit:
28.
UsingDockerfromWindowsCommandPrompt(cmd.exe)
1.LaunchaWindowsCommandPrompt(cmd.exe).
The docker-machine commandrequires ssh.exe inyour PATH environmentvariable.This .exe isintheMsysGit bin folder.
2.Addthistothe %PATH% environmentvariablebyrunning:
3.setPATH=%PATH%;"c:
\ProgramFiles(x86)\Git\bin"
4.CreateanewDockerVM.
5.docker-machinecreate--drivervirtualboxmy-default
6.CreatingVirtualBoxVM...
7.CreatingSSHkey...
8.StartingVirtualBoxVM...
9.StartingVM...
10.ToseehowtoconnectDockertothismachine,run:
docker-machineenvmy-default
ThecommandalsocreatesamachineconfigurationintheC:
\USERS\USERNAME\.docker\machine\machines directory.Youonlyneedtorunthe create commandonce.Then,youcanuse docker-machine tostart,stop,query,andotherwisemanagetheVMfromthecommandline.
11.Listyouravailablemachines.
12.C:
\Users\mary>docker-machinels
13.NAMEACTIVEDRIVERSTATEURLSWARM
14.my-default*virtualboxRunningtcp:
//192.168.99.101:
2376
IfyouhavepreviouslyinstalledthedeprecatedBoot2DockerapplicationorruntheDockerQuickstartTerminal,youmayhavea dev VMaswell.
15.GettheenvironmentcommandsforyournewVM.
16.C:
\Users\mary>docker-machineenv--shellcmdmy-default
17.Connectyourshelltothe my-default machine.
18.C:
\Users\mary>eval"$(docker-machineenvmy-default)"
19.Runthe hello-world containertoverifyyoursetup.
20.C:
\Users\mary>dockerrunhello-world
UsingDockerfromPowerShell
1.LaunchaWindowsPowerShellwindow.
2.Add ssh.exe toyourPATH:
3.PSC:
\Users\mary>$Env:
Path="${Env:
Path};c:
\ProgramFiles(x86)\Git\bin"
4.CreateanewDockerVM.
5.PSC:
\Users\mary>docker-machinecreate--drivervirtualboxmy-default
6.Listyouravailablemachines.
7.C:
\Users\mary>docker-machinels
8.NAMEACTIVEDRIVERSTATEURLSWARM
9.my-default*virtualboxRunningtcp:
//192.168.99.101:
2376
10.GettheenvironmentcommandsforyournewVM.
11.C:
\Users\mary>docker-machineenv--shellpowershellmy-default
12.Connectyourshelltothe my-default machine.
13.C:
\Users\mary>eval"$(docker-machineenvmy-default)"
14.Runthe hello-world containertoverifyyoursetup.
15.C:
\Users\mary>dockerrunhello-world
LearnaboutyourToolboxinstallation
ToolboxinstallstheDockerEnginebinaryintheC:
\ProgramFiles\DockerToolbox directory.WhenyouusetheDockerQuickstartTerminalorcreatea default VMmanually,DockerMachineupdatestheC:
\USERS\USERNAME\.docker\machine\machines\default foldertoyoursystem.ThisfoldercontainstheconfigurationfortheVM.
YoucancreatemultipleVMsonyoursystemwithDockerMachine.Therefore,youmayendupwithmultipleVMfoldersifyouhavecreatedmorethanoneVM.ToremoveaVM,usethe docker-machinerm command.
MigratefromBoot2Docker
IfyouwereusingBoot2Dockerpreviously,youhaveapre-existingDockerboot2docker-vm VMonyourlocalsystem.ToallowDockerMachinetomanagethisolderVM,youcanmigrateit.
1.OpenaterminalortheDockerCLIonyoursystem.
2.Typethefollowingcommand.
3.$docker-machinecreate-dvirtualbox--virtualbox-import-boot2docker-vmboot2docker-vmdocker-vm
4.Useth