Basic docker commands
Docker commands to get started
Here is a list of some commonly used Docker commands along with brief explanations that can help you get started with Docker:
docker run
: This command is used to run a Docker container based on a specific image. It creates and starts a new container instance from the specified image.docker pull
: It pulls or downloads a Docker image from a registry, such as Docker Hub or a private registry. This is the first step before running a container based on that image.docker images
: This command lists all the Docker images that are currently available on your system. It provides information such as the image ID, repository, tag, and size.docker ps
: It lists all the running Docker containers on your system. By default, it shows the container ID, image used, command being run, status, and ports.docker stop
: It stops a running container by specifying either the container ID or the container name.docker rm
: This command is used to remove one or more containers from your system. It requires specifying the container ID or container name.docker rmi
: It removes one or more Docker images from your system. You can specify the image ID or image name to remove.
If you remove the image that was used to create a running container using the docker rmi
command, the container will continue to run normally, unaffected by the removal of the image.
It's important to note that if you remove an image and later want to recreate or restart a container based on that image, Docker will not be able to pull the image again because it no longer exists locally.
Last updated