• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/27

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

27 Cards in this Set

  • Front
  • Back

What's Docker

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels

What's the difference from Docker and Virtual Machine

VM is piece of software that allows you to install other software inside of it so you basically control it virtually as opposed to installing the software directly on the computer. While a container is a software that allows different functionalities of an application independently.

How to build an image?

docker build -t myimage:1.0 .

How to run a container in docker ?

docker container run --name web

How to pull the logs from a container?

docker logs --tail 100 web

(Print the last 100lines of a container’s logs)

How to list running containers

docker container ls

How to list all the images in docker

docker image ls

What's Docker Hub

Docker's public repository for images

What's the difference between docker and docker-compose?

Docker commands are focused on only one container (or image) at once while docker-compose manage several containers docker.

What's the difference between CMD, RUN, EntryPoint?

RUN always creates a new intermediate image layer on top of the previous ones.
CMD command is used to set a default command that gets executed once you run the Docker Container. In case you provide a command with the Docker run command, the CMD arguments get ignored from the dockerfile. In the case of multiple CMD commands, only the last one gets executed.
ENTRYPOINT command, unlike CMD, does not ignore additional parameters that you specify in your Docker run command.

What's the difference between ADD, COPY ?

ADD - can copy from a directory or from a URL, it can copy a compressed files and automatically extract them.
COPY - cannot copy from URL. It copies just as-is

What's EXPOSE ?

EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. It doesn't publish the port.
To publish a port use "docker run -p 80:80"

How to optimize Docker image size ?

2) Base image as small as possible (alpine, busybox)


2) --no-install-recommends on install commands


3) clean-apt and remove temporary files
4) all commands in single RUN


5) use multistage dockerfiles, in stage1 to use full SDK, in stage2 use artifact from stage2 with runtime only

Rootless controller

Containers that can be created, run, and managed by users without admin rights.

Command to build an image

docker build -t <name>:<tag>

Command to list all images

docker images

Command to remove image

docker image rm <name>

Command to pull an image

docker pull <name>:<tag>

Command to push and image to the registry (repo)

docker push <name>:<tag>

Command to run a container

docker run <name>

Command to stop a container

docker stop <name>

Command to kill a container

docker kill <name>

Command list the networks

docker network ls

Command to list all running containers

docker ls


docker ps

to list even stopped containers add -a


docker ls -a


docker ps -a

Command to print last 100 lines of container's logs

docker logs --tail 100 <name>

Command to ssh into container

docker exec –it <name> /bin/bash

Command to run a command in the containers

docker exec -it <command>

docker exec -it echo "I'm inside the container!"


docker exec -it pwd


docker exec -it ls -l