Command basics – Getting started with docker on Windows (2016 TP4)

Since we know the Windows Server 2016 will support the Containers (Docker) we are very happy and exciting. We want to test and see how it works on Windows. Now we can use Windows Server 2016 TP4 as a great foundation.

This article shows some commands which useful when you work with Docker on windows and Windows Containers

Docker Command PowerShell Command Desctiption
start-process powershell -Verb runAs Start powershell on server where (“host”) you want to work with containers
Docker Images Get-ContainerImgage List docker images
Docker ps -a Get-Container List docker containers
docker run -it –name <new container name> <already existing image name> cmd
  • $oContainerImage = Get-ContainerImage <containerimage name>
  • New-Container -Name <Container name> -ContainerImage $oContainerImage -SwitchName “<Existing Virtual Switch name>”
  • Start-Container <Container name>
  • Enter-PSSession -ContainerName <Container name> -RunAsAdministrator
This command will instruct Docker to create a new Image from the already existing container and open console session (cmd) with the container.
docker run -it –name <new container name> -p <local port>:<container port> <already existing image name> cmd See previous It is similar than the previous line, but you counfigure ports for the communication between the “host” and the container. Example: -p 80:80 This is useful when we want to create an IIS on Docker
 docker rm <already existing container name>  Remove-Container <already existing container name>  Remove a container
 docker rmi <already existing image name>  Remove-ContainerImage <already existing image name>  Remove an image
 docker start <container name>  Start-Container <container name> Start stopped contaoner
 docker stop <container name>  Stop-Container <container name> Stop running container
 docker export <container image name> Filename.tar  Export-ContainerImage -Name <container image name> -Version <version of exportable> -Path “<Path of APPX file>”  Export existing container image to file
 docker exec -it <container name> cmd  Enter-PSSession -ContainerName <Container name> -RunAsAdministrator  Enter to a running container
 docker commit -a “Comment” <Base container ID> <New image name with version number>
  • $oContainer = Get-Container <container name>
  • New-ContainerImage -Container $oContainer -Name “<New image name>” -Publisher “<Author>” -Version “<Version of image like>”
 Build an image from your customized container
docker run -ti -v <source path>:<destination path> –name <new container name> <already existing image name> <internal shell>

example: docker run -ti -v C:\Data:C:\ExtData –name mounted windowsservercore cmd

Add-ContainerSharedFolder -ContainerName <Container name> -SourcePath “<Fileshare UNC path> -DestinationPath “<Path inside container. G: or C:\ExtData>” -AccessMode ReadWrite Mount volume (docker) and file share (windows) to container

Be the first to comment on "Command basics – Getting started with docker on Windows (2016 TP4)"

Leave a comment