WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Docker · Basic · question 10 of 100

What are some common Docker commands, and what do they do?

📕 Buy this interview preparation book: 100 Docker questions & answers — PDF + EPUB for $5

Here are some common Docker commands and what they do:

docker run: This command starts a new Docker container based on a specified image. The docker run command can be customized with a variety of options and arguments, such as port mapping, environment variables, and volume mounting.

For example, to start a new Docker container based on the nginx image and expose port 80 on the host system, you would run the following command:

    docker run -p 80:80 nginx

docker build: This command builds a new Docker image based on a specified Dockerfile. The docker build command can be customized with a variety of options and arguments, such as caching, build-time variables, and tag naming.

For example, to build a new Docker image for a Node.js web application using a Dockerfile located in the current directory and tag it as my-node-app, you would run the following command:

    docker build -t my-node-app .

docker images: This command lists all of the Docker images that are currently available on your local system. The docker images command displays information about each image, such as its name, tag, size, and creation date.

    docker images

docker ps: This command lists all of the Docker containers that are currently running on your local system. The docker ps command displays information about each container, such as its container ID, image name, and status.

    docker ps

docker stop: This command stops a running Docker container. The docker stop command sends a SIGTERM signal to the container, allowing it to gracefully shut down and exit.

    docker stop container_name_or_id

docker rm: This command removes a stopped Docker container. The docker rm command permanently deletes the container and its associated resources, such as volumes and network connections.

    docker rm container_name_or_id

docker rmi: This command removes a Docker image from your local system. The docker rmi command permanently deletes the image and all of its associated layers.

    docker rmi image_name_or_id

docker login: This command logs in to a Docker registry, such as Docker Hub, to access private images or repositories. The docker login command requires a Docker Hub account and valid credentials.

    docker login

docker push: This command uploads a Docker image to a Docker registry, such as Docker Hub. The docker push command requires a Docker Hub account and valid credentials.

    docker push image_name

docker pull: This command downloads a Docker image from a Docker registry, such as Docker Hub. The docker pull command retrieves the image and all of its associated layers.

    docker pull image_name

These are just a few of the many Docker commands that are available. Each command has its own set of options and arguments, and Docker provides extensive documentation and examples on its website.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Docker interview — then scores it.
📞 Practice Docker — free 15 min
📕 Buy this interview preparation book: 100 Docker questions & answers — PDF + EPUB for $5

All 100 Docker questions · All topics