Docker Flashcards

1
Q

How to login?

A

docker login harbor.fleetcomplete.dev -u username -p password

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

How to fetch an image?

A

docker pull registry.aquasec.com/console:6.2.21171

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

How to tag?

A

docker tag 12345 my.registry/my.image:1

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

Check logs?

A

docker logs 12345 –follow

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

Delete image?

A

docker rmi gitlab/gitlab-ce:13.12.5-ce.0

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

Delete container?

A

docker stop gitlab # first stop the container though
docker rm gitlab # removes the container already running.
.

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

Running containers shared the kernel with the underlying host OS?

A

True

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

Kubernetes vs Docker

A

K8S is the orchestrator of containerized apps. By default uses Docker as container runtime.

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

ContainerD

A

A specialized part of docker that takes care of low level tasks like stopping and starting contianers.

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

Docker as a technology

A

= RUNTIME + DAEMON/Engine + Orchestrator/Swarm

Orchestrator.

Daemon(dockerd) = RemoteAPI + Networking + Volumes + Image mgt .. etc

Runtime = containerd(higher level maintains the complete lifecycle of an image) + runc(lower level interfaces with underlying OS)
Responsibel for OS constructs, cgroups and namespaces.

dockerd communicates with containerd over grpc

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

OCI

A

Open Cotainer Initiative

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

Docker Installation

A

Docker Client
Docker Daemon/Engine

The client talks to daemon via local Unix socket

/var/run/docker.sock
docker client can execute commands through docker.sock on daemon.

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

Check docker images

A

docker image ls

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

Run an image

A

docker container run -it ubuntu:latest /bin/bash

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

List containers running

A

docker container ls

docker container ls -a # list all containers

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

Attach to a running container

A

docker container exec gitlab -it /bin/bash

17
Q

Build a docker image

A

docker image build -t myimage:123 .

18
Q

Run an image as a container

A

docker container run -d –name myweb –publish 8080:8080 myimage:123

-d run in the background

19
Q

What is runc?

A

runc is a CLI wrapper for libcotainer that was originally designed to replace the LXC.

20
Q

What is a dangling image?

A

Image without any tag.

docker image ls –filter dangling=true

21
Q

How to check manifest of an image

A

docker image manifest ubuntu:latest

22
Q

How to make a container restart automaticaller

A

docker container run –name neversaydie -it –restart always alpine:latest sh
–restart unless-stopped

23
Q

Example gitlab volume mount

A

docker run –detach \
–hostname gitlab.fleetcomplete.com \
–publish 443:443 –publish 23:22 –publish 80:80 \
–name gitlab \
–restart always \
–volume /src/gitlab/config:/etc/gitlab \
–volume /src/gitlab/logs:/var/log/gitlab \
–volume /src/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:fc-latest

24
Q

docker-compose yaml example

A
version: "3.8"
services:
  web-frontend:
    build: .
    command: python app.py
    ports:
      - target: 5000
        published: 5000
    networks:
      - counter-net
    volumes:
      - type: volume
        source: counter-volume
        target: code
  redis:
    image: redis:alpine
    network:
      - counter-net
networks:
  counter-net:
volumes:
  counter-volume:
25
Q

List network

A

docker network ls

26
Q

List volumes

A

docker volume ls

27
Q

Start an app using docker compose

A

docker-compose -f myapp.yaml up -d

docker-compose -f myapp.yaml down # stops and deletes the containers.

docker-compose restart
docker-compose ps