Helpful commands for docker newbies like myself.
# List all docker images you have.
PS C:\> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 46102226f2fd 12 days ago 109 MB
centos-rl latest 647c13af08c7 2 weeks ago 302 MB
ubuntu latest 6a2f32de169d 3 weeks ago 117 MB
centos latest a8493f5f50ff 4 weeks ago 192 MB
d4w/nsenter latest 9e4f13a0901e 7 months ago 83.8 kB
# Pull a new docker image:
PS C:\> docker pull <image_name>
# List docker containers both active and not actively running
PS C:\> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c8ef567a8bdc centos-rl "/bin/bash" 3 hours ago Exited (0) 4 minutes ago centos-rl-tools
7f9f3afa7a3f nginx "nginx -g 'daemon ..." 4 hours ago Up 4 hours 0.0.0.0:32769->80/tcp nginx-the-cross.net
# Rename docker container
PS C:\> docker container rename Old-Name New-Name
# Remove a container
PS C:\> docker rm conainter_Name
or
PS C:\> docker rm conainter_ID
# Delete image
PS C:\> docker rmi Image_ID
# Run docker container on Windows 10 with host volume
PS C:\> docker run -it -v D:/docker/centos-rl:/data centos-rl
# The "run" command should only be used the very first time you run the image. This creates a new container.
PS C:\> docker start -i centos-rl-tools
# Use "start" for subsequent uses. This starts the container that was previously created. The image remains unmodified. Your volume will still be mapped, along with any other parameters you used with "run" command.
# Run docker container in detached mode:
PS C:\>docker run --name centos-rl -p 8080:80 -e TERM=xterm -d nginx
# To access the container:
PS C:\>docker exec -it <CONTAINER_ID> bash
# Export docker container to tar file.
PS C:\> docker ps -a #to list image name.
PS C:\> docker save -o D:/Temp/centos-rl.tar centos-rl
# Import/Load docker image
PS C:\> docker load -i D:/Temp/centos-rl.tar