EssentialDockerforASP.NETCoreMVC
Find out how to use Docker in your ASP.NET Core MVC applications, and how containers make it easier to develop, deploy and manage those applications in production environments. Packed with examples and practical demonstrations, this book will help you deploy even large-scale, cross-platform web applEssential Docker for ASP.NET Core MvCAdam freemanLondon ukISBN-13(pbk):978-1-4842-2770ISBN-13( electronic:978-1-4842-2778-7DOI10.1007/978-1-4842-27787Library of Congress Control Number: 2017938878Copyright o 2017 by Adam FreemanThis work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of thematerial is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storageand retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known orhereafter developedTrademarked names, logos, and images may appear in this book. Rather than use a trademark symbol withevery occurrence of a trademarked name, logo, or image we use the names, logos, and images only in aneditorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademarkThe use in this publication of trade names, trademarks service marks, and similar terms, even if they arenot identified as such, is not to be taken as an expression of opinion as to whether or not they are subject toproprietary rightsWhile the advice and information in this book are believed to be true and accurate at the date of publicationneither the authors nor the editors nor the publisher can accept any legal responsibility for any errors oromissions that may be made. The publisher makes no warranty, express or implied, with respect to thematerial contained hereinManaging Director: Welmoed SpahrEditorial director. Todd greenAcquisitions Editor: Gwenan SpearingDevelopment Editor: Laura berensonTechnical reviewer: Fabio Claudio ferracchiatiCoordinating Editor: Mark PowersCopy Editor: Kim WimpsettCompositor: SPi GlobalIndexer: SPi GlobalArtist SPi globalCover image designed by FreepikDistributed to the book trade worldwide by Springer Science+ Business Media New York,233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-maorders-ny@springer-sbm.comorvisitwww.springeronline.com.ApressMedia,LlcisaCaliforniaLlcand the sole member(owner) is Springer Science Business Media Finance Inc(SSBM Finance Inc)SSBM Finance Inc is a Delaware corporationForinformationontranslationspleasee-mailrights@apress.com,orvisithttp://www.apress.com/rights-permissionsapress titles may be purchased in bulk for academic, corporate, or promotional use e Book versions andlicenses are also available for most titles For more information reference our print and e Book bulk sales webpageathttp://www.apress.com/bulk-salesAny source code or other supplementary material referenced by the author in this book is available toreadersongIthubviathebooksproductpagelocatedatwww.apress.Com/9781484227770.Formoredetailedinformationpleasevisithttp://www.apress.com/source-codePrinted on acid-free paperDedicated to my lovely wife Jacqui griffith(And also to Peanut)Contents at a glanceAbout the author…nxiAbout the technical reviewer■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■vChapter 1: Understanding Docker EmmmmmmR aAaaaa. 1Chapter 2: Essential Docker Quick Reference mamma aaaaaa 7Chapter 3: Getting Ready.■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■m■17Chapter 4: Docker Images and containers .amaammmmaam 39Chapter 5: Docker Volumes and Networks■■■■■■■■■■口■■■■■■■■■■■口■■■■■■■■口■■■■■■■■■■■■■■■■■69Chapter 6: Docker Compose .mamma EIIn 97Chapter 7: Docker Swarmsamama aInn 119Chapter 8: Containerized Developmentna145Index■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■169ContentsAbout the author…nxiAbout the technical reviewer■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■vChapter 1: Understanding DockerWhat do you need to knowWhat is the structure of this book?量日面日日日面日日日面日日自日量日面日自日日面日日日日面日日日面日日自日面量日面日日重1Is This an Exhaustive docker Reference?DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDAre There Lots of Examples?2Which Operating Systems Are Supported?2Why should You care About Docker?2What Is the Consistency Problem?....................2What Is the Responsiveness Problem? ......................Aren't Docker Containers just virtual machines?Do Docker Containers have limitations?Do You have to use docker to Use containers?How do You set up your development Environment?Contacting the AuthorDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD44566667SummaryDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDChapter 2: Essential Docker Quick Reference B RRRARIBRRRRRERIIDDocker Images Quick ReferenceDocker Containers quick referenceDocker Volumes Quick Reference10Docker Software-Defined Networks Quick ReferenceCONTENTSDocker Compose Quick Reference12Docker Swarm Quick ReferenceSummary,16Chapter3: Getting Ready,,,,…,…,………,…,…,,,…17Installing the Required Software Packages17Installing the NeT Core Software development kit18Installing Node. js20Installing the npM package22Installing Git..22Installing Docker.Installing an IDE28Testing the Development Environment0Creating the Example MVC Application .mmmmmmmmanmnmammm...n 31Creating the Project..32Confithe client-Side Packages32Creating the Data Model and Repository .Preparing the controller and vier35Configuring ASP. NET and Creating the Entry Point..............Running the MVC Application37Summary…38Chapter 4: Docker Images and containers a■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口39Preparing for This chapter40Working with ImagesDownloading Images.Deleting Images,,,,…42Creating a Docker File for a Custom Image43Preparing the application for the Image45Creating a custom imageCONTENTWorking with ContainersCreating containers日面日日Listing containers....................,………………,47Starting Containers…....….…………….47Stopping Containers9Getting Container Output..日面口ing Containers with a single command…..,,…,…,…,…,…,…,Modifying Containers51Changing a Container………52EXamining changes to a Container..............………….54Executing Commands in Containers55Creating Images from Modified ContainersPublishing Images58Tagging the Images for PublicationAuthenticating with the Hub..…………………59Publishing the Images……Creating Windows containers61Switching to Windows containers...Creating a NET Core Windows Image.Executing commands in Windows containers65Summary67Chapter 5: Docker Volumes and Networks ann. 69Preparing for This chapter70Working with VolumesDemonstrating the ProblemManaging Data with a Docker Volume.…,…,…,…,…,…,,…,…,…,……………………72Determining whether an Image Uses volumes74CONTENTSAdding a database to the Example application74Pulling and Inspecting the database ImageCreating the Volume and container…76Preparing the Example Application.…......,,……,…,………………77Creating the Repository Classn78Configuring the application .Creating the Database Migration81Changing the viewCreating the MVC Application Image83Testing the Application.…...............,,...,.,…….……,83Working with Software-Defined Networks.Scaling the MvC Application.…………87creating Custom Software-Defined NetwCreating Custom NetworksworksSummary95Chapter 6: Docker Compose■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■a■97Preparing for This chapter98Changing the view messageInstalling Docker Compose on LinuxCreating the compose File,99Composing the database,101Testing the application Setup and Teardown103Database Preparation and Mvc Composition104Modifying the MVC Application104Describing the Database Initialization and Mvc services107Composing the Load Balancer110Running the application...........……,112Processing the compose File…112Preparing the Database….....….,113Starting the MVC Application......................................113CONTENTSScaling the MvC Service114Stopping the applicationDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD116SummaryDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD117Chapter 7: Docker Swarms.amaNn 119Preparing for This chapter121Preparing the Swarm121Creating the swarm…122Labeling Swarm Nodes.................123Manually Deploying Services on a Swarm.Creating the Software-Defined NetworksCreating the Database service .Creating the MVC Application Service129Creating the Load BalancerRemoving the Service from the Swarm,135Deploying to a Swarm Using a compose File..135Performing the deployment....………………136Preparing the database137Creating the Deployment Load Balancer..........138Managing the Swarm138Scaling services.................................Taking Nodes Out of Service.....139Updating a service.Shutting down Services....................................142Creating Global Services142Summary144Chapter8: Containerized Development,,,,,,,…,,,,,……,…145Preparing for This chapter…...…146Using Development Mode to Prepare the Database146Understanding Containerized ASP NeT Core Development147
用户评论
感谢,比从网站下载快。
非常感谢分享!
非常好,感谢分享!