Docker Commands Flashcards

1
Q

What is tag in docker image ?

A

While pulling the docker image , version of image is tag
like **redis:4.0 ** is a tag

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

WhaT is the default tag ?

A

latest version is default tag

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

Where we know the tags of images ?

A

In docker hub we see the image tags

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

What is a command to run a docker

A

docker run dockerImage

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

How to view running containers

A

docker ps

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

How to view stoped containers

A

docker ps -a

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

How to stop docker

A

docker stop dockerName/dockerID

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

How to view downloaded images

A

docker images

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

How to delete stored images ?

A

docker rmi imageID/RepoName

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

How to download only docker image

A

docker pull imageName

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

How to run a docker in detached mode

A

docker -d dockerImage

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

How to attach a detached docker ?

A

docker attach dockerName/ID

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

How to check docker version ?

A

docker version

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

How to view docker network connections

A

docker network ls

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

What are tags in docker ?

A

Image versions are docker tags

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

How to download docker image by tag

A

Image name followed by : colon
docker pull redis:7.2.3-alpine3.18
or
docker pull redis:latest

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

How to mount a host directory in docker container

A

docker run -v /opt/dataDir:/var/lib/mysql mysql

18
Q

How to run a docker with name

A

docker run –name thor centos

19
Q

How to check logs of running container ?

A

docker logs container-name

20
Q

Run docker from busybox image , auto remove after stop , autologin & detached , also name a container .

A

docker run –name thor –rm -itd busybox

21
Q

How to get os relese info of docker ?

A

docker run ubuntu cat /etc/rel

22
Q

How to run docker container for 2 minutes

A

docker run ubuntu sleep 120

23
Q

How to pull the latest tag of ubuntu version

A

docker run ubuntu:latest

24
Q

How Map a host port to docker container port

A

docker run -p 4000:8080 kodekloud/webapp

25
How to get Full details of running container
docker inspect container_ID
26
How to list running containers
docker ps ps stands for **Process Status**
27
How to list stopped & running containers
docker ps -a
28
How to kill running container
docker stop containerName
29
How to remove an , stopped or running container
docker rm imagename or id
30
How to remove downloaded docker image
1. First check container is not running, stop it if running 2. remove the stopped container 3. Now you are able to remove the docker container image
31
How to download only docker image
docker pull image_name
32
How to run docker container for 6o seconds
docker run ubuntu sleep 60
33
How to run command in running container
`**docker exec dockerID cat /etc/*rel***`
34
How to run docker image in detached mode
docker run -d ubuntu
35
How to attach docker container
docker attach dockerID
36
How to run a docker image as , login to docker container & attache it to host terminal
docker -it ubuntu bash
37
What is Docker run command ?
Docker Run Command is used to run a container from an image
38
What is an docker Repository
Docker Account which holds the docker images
39
How to see the exit code of stopped container
docker ps -a Now see the Status , a number in brackets is the exit code
40
How to run a container in Background
docker -d ubuntu sleep 100
41
Where is docker container runs
Docker Container runs under Docker Host or Docker Engine