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
Q

How to get Full details of running container

A

docker inspect container_ID

26
Q

How to list running containers

A

docker ps
ps stands for Process Status

27
Q

How to list stopped & running containers

A

docker ps -a

28
Q

How to kill running container

A

docker stop containerName

29
Q

How to remove an , stopped or running container

A

docker rm imagename or id

30
Q

How to remove downloaded docker image

A
  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
Q

How to download only docker image

A

docker pull image_name

32
Q

How to run docker container for 6o seconds

A

docker run ubuntu sleep 60

33
Q

How to run command in running container

A

**docker exec dockerID cat /etc/*rel***

34
Q

How to run docker image in detached mode

A

docker run -d ubuntu

35
Q

How to attach docker container

A

docker attach dockerID

36
Q

How to run a docker image as , login to docker container & attache it to host terminal

A

docker -it ubuntu bash

37
Q

What is Docker run command ?

A

Docker Run Command is used to run a container from an image

38
Q

What is an docker Repository

A

Docker Account which holds the docker images

39
Q

How to see the exit code of stopped container

A

docker ps -a
Now see the Status , a number in brackets is the exit code

40
Q

How to run a container in Background

A

docker -d ubuntu sleep 100

41
Q

Where is docker container runs

A

Docker Container runs under Docker Host or Docker Engine