Skip to content

Instantly share code, notes, and snippets.

@g0t4
Last active July 11, 2022 14:53
Show Gist options
  • Star 64 You must be signed in to star a gist
  • Fork 23 You must be signed in to fork a gist
  • Save g0t4/0d97a9595c87736a8a72a2bd21afc0d9 to your computer and use it in GitHub Desktop.
Save g0t4/0d97a9595c87736a8a72a2bd21afc0d9 to your computer and use it in GitHub Desktop.
Getting Started with Docker on Windows
  • Containers are about Software!
  • Traditionally we use the following process to run software:
    • Find the software, usually a standalone web site.
    • Download the software, usually a zip file or some sort of installer.
    • Then we install the software, often extracting a zip file or running an installer.
    • Then we run the installed software.
  • You can learn alot about containers by relating them to the process above. Here's what it looks like to run software with containers:
    • Find the software, on Docker Hub.
    • Download the software with docker pull, comes down as an image which is much like a zip file or msi installer. An image is an application packaging format.
    • Instead of installing the software, we create a container. So, a container--a stopped container--is like installed software. Docker unpacks the image onto the computer, creating a container. Note: if you just want to create a container, you can use docker create.
    • Then we run the container which is exactly like running an exe. It's the same thing under the covers!!!
    • We often use docker run to orchestrate all of these steps with one command, how convenient!
  • docker exec can be thought of as running another copy of our installed software, like when we launch an executable twice. For example, two copies of Microsoft Word. Or with MongoDB, we might run two mongo clients. After a container is created and running, we can use docker exec to run multiple applications, or multiple copies of the same app, inside the container.
# DISCLAIMER: I cannot guarantee the safety of any image
# Use your judgement before running software you download from the internet
# Open PowerShell
# 1. nmap (linux container)
# Port scan your home network
# - Replace 192.168.0.0 with your network
# - Don't be scanning networks you don't own!
# https://hub.docker.com/r/weshigbee/nmap/
docker run --rm `
weshigbee/nmap -v 192.168.0.0/24
# 2. ffmpeg (linux container)
# - Replace Turkey.mp4 with whatever movie you'd like to turn into an animated gif
# - Turkey Video: http://www.weshigbee.com/wp-content/uploads/2014/12/Turkey-Short.mp4
# - http://bit.ly/2fcrRK2
# https://hub.docker.com/r/jrottenberg/ffmpeg/
docker run --rm `
# mount host's current directory as /output inside container
--volume ${pwd}:/output `
jrottenberg/ffmpeg -i http://bit.ly/2fcrRK2 /output/Turkey.gif
# 3. .NET Core (linux container)
# Make a sample ASP.NET Core web app
# https://hub.docker.com/r/microsoft/dotnet/
mkdir web-dotnet
# - A Get help
docker run --rm \
microsoft/dotnet \
dotnet help new
# - Create web sample
docker run --rm \
--volume $(pwd)/web-dotnet:/workspace \
--workdir /workspace \
microsoft/dotnet \
dotnet new -t web
# - Run shell
docker run --rm \
--volume $(pwd)/web-dotnet:/workspace \
--workdir /workspace \
-p 5000:5000 \
-it \
microsoft/dotnet \
bash
# then run these in bash shell in container:
dotnet restore
export ASPNETCORE_URLS=http://+:5000
dotnet run &
curl localhost:5000

Docker : A front end for managing continers.

# Source: https://msdn.microsoft.com/en-us/virtualization/windowscontainers/deployment/deployment
#replace with the virtual machine name
$vm = "Win10DockerGettingStarted"
#configure virtual processor
Set-VMProcessor -VMName $vm -ExposeVirtualizationExtensions $true -Count 2
#disable dynamic memory
Set-VMMemory $vm -DynamicMemoryEnabled $false -StartupBytes 8GB
#enable mac spoofing
Get-VMNetworkAdapter -VMName $vm | Set-VMNetworkAdapter -MacAddressSpoofing On
# Solitaire static web site
# 1. Use volume mounts to host static site
docker run --rm -it `
-v ${pwd}/app:/usr/share/nginx/html `
-p 8080:80 `
nginx
docker run --rm -it `
-v ${pwd}/app:/usr/share/nginx/html `
-p 8080:80 `
microsoft/iis
# 2. Copy files into container
docker run -d -p 8080:80 --name nginx nginx
docker cp app/. nginx:/usr/share/nginx/html
# 3. Commit container to make an image!
docker commit nginx solitaire:nginx
# 4. Dockerfile (save the two lines below in a file called Dockerfile)
FROM nginx
COPY app /usr/share/nginx/html
# build
docker build -t solitaire:nginx-dockerfile .
# MSSQL
# SSMS Management Tools free download: https://msdn.microsoft.com/en-us/library/mt238290.aspx
@derek987654
Copy link

In the Docker-Compose module, received an error pulling down sjoerdmulder/teamcity-agent. Had to modify the docker-compose file to request this image instead:

image: jetbrains/teamcity-agent

Then, error when trying to connect to the Postgress database. Had to update the Postgress container definition with this environment setting:

  • POSTGRES_HOST_AUTH_METHOD=trust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment