Docker Commands Flashcards

1
Q

What is “docker run” command?

A

The Docker run command is used
to run a container from an image. Running the docker run nginx command will run an instance of the nginx application on the Docker host if it already exists. If the image is not present on the host, it will go out to Docker hub and pull that image down.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the “docker ps” command?

A

The docker ps command lists all running containers and some basic information about them such as the container lD., the name of the image we used to run the containers, the current status, and the name of the container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is the ID and name created for the containers in docker?

A

Each container automatically gets a random lD. and name created for it by Docker

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is “docker stop” command?

A

To stop a running container, use the docker stop command, but you must provide either the container l.D. or the container name in the stop command. If you’re not sure of the name, run the docker ps command to get it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the “docker rm” command?

A

Use the docker rm command to remove a stopped or exited container permanently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How long does a container live?

A

Container only lives or is alive as long as the process running inside it.
Once the task is complete, the container exits. A container only lives as long as the process inside it is alive.
If the web service inside the container is stopped or crashed, then the container exits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What command to use if you just want the image, but do not want to run a container using that image?

A

docker pull <image-name>
eg. docker pull ubuntu</image-name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Docker command to remove an image?

A

docker rmi <image-name></image-name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what does “docker images” command do?

A

Lists all the downloaded or locally available images

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the two modes of running the “docker run” command

A
  1. Foreground or attached mode
  2. Detached mode
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

which is the default docker repository which has the official images?

A

library

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the difference between exec and -it

A

docker exec is used to execute a command in a container and get the output in the std out.

-it option is used with docker run command and is used to get into the bash or get inside the container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is docker run in detached mode

A

use that using -d option with docker run. That is used to have the docker container running in the background. You can get back to the prompt to run other commands in detached mode. In attached mode you will be attache dto the container not coming out of prompt to enter any other commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Command to force kill a docker container?

A

docker stop <container-name></container-name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

command to remove a stopped or exited container permanently

A

docker rm <container-name></container-name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what option to use in docker run command when you want to name the container?

A

–name
The order is important. eg
docker run –name webapp nginx:1.14