TABLE OF CONTENTS1. Introduction2. Technologies Leveraged3. Prerequisites4. Preparing MongoDB Docker image5. Preparing Grandnode Docker image6. Running the E-Commerce Application Locally7. Creating a Container Registry for Application Container Image Images8. Pushing Images to The Registry10. Conclusion 11. CloudThat12. FAQs
Introduction
Containerization offers us the advantage of rapid deployment, scaling, patching, and maintenance of our applications. A.NET application can also be migrated to Windows containers easily without having to modify the code. A Dockerfile must be prepared to containerize your application. Container registries such as DockerHub and Azure Container Registry allow for portability and agility. They allow us to create custom versions of our applications faster than virtual machines and enable us to spin them up quickly.
Technologies Leveraged
Docker
Grandnode
MongoDB
Azure Container Registry
Prerequisites
Azure account
GitHub account
Azure CLI
Windows Server 2019/Windows 10 (If you are using a different operating system, please use the corresponding source code to make the necessary changes to the entire setup.
Docker
Preparing MongoDB Docker Images
1. Clone the GitHub repo at “https://github.com/aneez004/mongo-windows.git”. Next, move to the git folder.
2. Modify the mongodbuser.ps1 File
3. You can either add a database username or password, or leave the defaults. Here, we add the user “grandadmin”, with the password “grand”, to the database administrator. We use the mongo windows image for the Dockerfile. To create the db user, we copy the PowerShell script.
4. Tag the docker image using a preferred name.
Docker build -t
1. Clone the Github repo at “https://github.com/aneez004/grandnode2.git”. Navigate to the “grandnode2” folder.
2. Verify the Dockerfile.
3. Tag the image and build it.
Docker build -t
Locally running the E-Commerce Application
1. Run the mongodb container.
docker run -d -p 27017:27017 -name mongodb aneez004/mongo:grandnodev1
2. You can run the grandnode-dock container by linking to mongodb.
docker run -d -p 8080:80 -link mongodb:mongo -name grandnode aneez004/grandnode:v1
3. Verify that both containers are operational
Docker ps
4. Access the application from a browser at http://localhost:8080
5. Enter your company information. Enter your company information under ‘Store Information’.
6. Enter the following details under ‘Database Information’:
Name of the MongoDB Server: MongoDB (the exact mongoDB name that you specify using the -name option during dockerrun)
b. Name of the database: admin
c. Username Grandadmin (replace what you have given in mongodbuser.ps1)
d. Password Grand (replace what you have given in mongodbuser.ps1)
Click on Install.
7. Restart the grandnode.
8. Access the application at http://localhost:8080
To modify your E-Commerce website, access the admin page. Enter the administrator username and password you received during grandnode installation.
Register for Container Images
1. Log in to Azure portal. If you don’t have an account, create a free account at https://azure.microsoft.com/en-us/free/
2. Search for and select ‘Container Registries.
3. Click on Register container
4. Please select your subscription and create a new resource category.
5. Note down the unique “Registry Name” for future reference.
6. Accept default settings for the remaining settings. Then select Review + create. After reviewing the settings, click Create.
Notify the registry name and login server.
Pushing Images to Th