I am a beginner in docker and referring this to install and understand basics but I am little confused about run and pull command.
What is the difference between docker run and docker pull commands for Docker images?
docker pull pulls an image or a repository from a registry. docker run runs a command in a new container.
The docker pull command downloads Docker images from the internet. The docker image command lists Docker images that are (now) on your computer. The docker run command creates running containers from images and can run commands inside them.
The 'docker pull' is a Docker command to download a Docker image or a repository locally on the host from a public or private registry. When we run any container and the specified Docker image is not present locally then it first pulls it from the registry.
Docker allows you to run a container in interactive mode. This means you can execute commands inside the container while it is still running.
docker run runs an instance of a container. In order to do that it will pull all the required images needed to run the container (i.e. base images) in the background if they are not part of the local cache.
docker pull will fetch/pull an image from the docker registry.
Think of it similar to git fetch and git pull if you have worked with git.git pull will do git fetch (and git merge)
From the docs:
docker run:
The
docker runcommand firstcreatesa writeable container layer over the specified image, and thenstartsit using the specified command. A stopped container can be restarted with all its previous changes intact usingdocker start. Seedocker ps -ato view a list of all containers.
If the image you are trying to run is not downloaded yet it will be automatically fetched with pull.
docker pull:
Most of your images will be created on top of a base image from the Docker Hub registry.
Docker Hub contains many pre-built images that you can
pulland try without needing to define and configure your own.To download a particular image, or set of images (i.e., a repository), use
docker pull.
So docker pull will download or update an image.
Pull will download new versions of images if there are any, while run will only download an image if you don't have a local copy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With