Docker Commands - A Quick 5 Minute Refresher
This guide is intended for anyone who hasn't used Docker in awhile and is just looking for a quick refresher on command syntax of frequently used Docker commands to run, configure, and manage containers and images.
List and Update / Get Your Docker ImagesTo see what Docker images you have on your machine.
docker images- To list all Docker images on your system
docker inspect <Image ID>- To get more details of the image in JSON
docker rmi <Image ID>- To delete an image from your system
docker pull <Repository>:<Tag>- To update or get an image you need to reference the image using the Repository and Tag
Managing Your Containers
docker ps- To list all your currently running containers
docker ps -a- List all persistent containers you have on your system
docker rm <Container ID>- To delete a container from your system
If all your containers and images are stale and you just want to start with a clean system.
docker system pruneis the command you are looking for. Best to review the official docker documentation on the command here.
Let's Get Running...
If you are looking to create a new container from an image and interactive with it:
If you are looking start an existing container and interactive with it:
Share Host Folder with Container
If share a host system folder with a new container using the -v parameter. The key thing to remember is you supply the full host path separated by a colon and the path you want it to mount as in the container.
Set an Environment Variable in the Container
To set an environment variable in a new container using the -e parameter. The key thing to remember is you use declare the variable name uses the equal sign set its value.
Post a Comment