DevOps Classroom Series – 19/Sept/2021

Docker compose

  • Docker compose is a tool for defining and running multi container Docker applications
  • Docker compose is written as a yaml file and Refer Here for the yaml file reference
  • create a yaml file as shown below
---
version: "3.8"
services: 
  web:
    build: .
    ports:
      - 8080:8080
  database:
    image: mysql
    environment: 
      MYSQL_ROOT_PASSWORD: directdevops
      MYSQL_DATABASE: test
      MYSQL_USER: directdevops
      MYSQL_PASSWORD: directdevops
    volumes:
      - type: volume
        source: db_data
        target: /var/lib/mysql
volumes:
  db_data: {}

  • Now docker-compose up -d will create images and start all the containers & docker-compose down will remove all the containers started.

Docker on Windows

  • From Windows 10 and Windows Server 2016 microsoft has added the support for running docker container natively on windows, prior to that on windows container were created using hypervisors (virtual box/hyperv)
  • On Windows Systems, We can run docker containers with windows images as well as linux images,
  • Windows containers cannot be run on the linux nodes
  • Create a Windows Server and Enable the windows feature Containers
    • Launch Powershell as Admin and Execute
    Install-WindowsFeature -Name Containers
    UnInstall-WindowsFeature Windows-Defender
    Restart-Computer -Force
    
  • Install Docker on Windows Server 2019 Refer Here
    • Launch Powershell as Admin and Execute
    Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
    Install-Package -Name docker -ProviderName DockerMsftProvider
    Restart-Computer -Force
    
    • Login into the machine Launch Powershell as Admin again
    Start-Service Docker
    
    docker pull mcr.microsoft.com/windows/servercore:ltsc2019
    
    • Lets quickly write one docker file to enable iis server with some html page using the above as base image
FROM mcr.microsoft.com/windows/servercore:ltsc2019
LABEL maintainer='khaja'
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
RUN echo "Hello World - Windows Container" > c:\inetpub\wwwroot\index.html
CMD ["cmd"]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube