- Learning Windows Server Containers
- Srikanth Machiraju
- 365字
- 2021-07-02 23:23:27
Running web application in Docker
Now let's start creating our first image using the Dockerfiles approach:
- Create a folder under C:\ on Windows Server Containers host machine for storing our image artifacts; let's call it learningwsc-chapter2.
- Create another folder within learning-chapter2/hellodocker, which will hold the artifacts for our first image.
- Open a text editor such as notepad and copy the following contents into the file:
FROM microsoft/windowsservercore
MAINTAINER srikanth@live.com
LABEL Description="IIS" Vendor=Microsoft" Version="10?
RUN powershell -Command Add-WindowsFeature Web-Server
COPY index.htm /inetpub/wwwroot/
EXPOSE 80
CMD [ "ping localhost -t" ]
- Save this file as Dockerfile under learningwsc-chapter2/hellodocker.
- Make sure the file is saved without any extension.
To save a file without any extensions under Windows, just surround the filename with "". In this example, save the file as "Dockerfile".
- Open notepad again and copy the following contents:
<h1> Hello from Docker !! </h1>
- Save the file as index.htm under learningwsc-chapter2/hellodocker. This serves as our simple HTML application.
Since this book is all about working with Windows Server Containers, the sample applications used to package as containers will be made as simple as possible. However, the same methodologies can be applied for any complex applications. The packaging process is completely decoupled from the application development.
- Now that we have all the artifacts ready we can build our first Docker image. Press the Windows key on your keyboard and type PowerShell.
- Right-click Windows PowerShell and Run as Administrator.
- Navigate to the folder that contains our artifacts, which is in learningwsc-chapter2/hellodocker:
Cd\
Cd learningwsc-chapter2\hellodocker
- Run the following command to build our first Docker image:
docker build -t hellodocker .
Downloading the example code
Detailed steps to download the code bundle are mentioned in the Preface of this book. The code bundle for the book is also hosted on GitHub at: https://github.com/PacktPublishing/Learning-Windows-Server-Containers. We also have other code bundles from our rich catalog of books and videos available at: https://github.com/PacktPublishing/. Check them out!
- The output should look as follows:

- Ensure that the log ends with Successfully built [imageidentifier], as shown previously. The image identifier here is the unique ID provided to our image by Docker Engine.
- You should now be able to see your hellodocker image in the Docker image list:

- 構建高可用Linux服務器(第4版)
- Ansible權威指南
- Persistence in PHP with the Doctrine ORM
- Haskell Financial Data Modeling and Predictive Analytics
- SOA實踐者說
- SharePoint 2013 應用開發實戰
- 嵌入式Linux驅動程序和系統開發實例精講
- 計算機系統開發與優化實戰
- Mobile First Design with HTML5 and CSS3
- Mastering Reactive JavaScript
- Linux系統最佳實踐工具:命令行技術
- Learn SwiftUI
- 統信UOS應用開發進階教程
- Responsive Web Design with AngularJS
- 電腦辦公(Windows10+Office2016)從新手到高手