Debug School

Edwin Piastro
Edwin Piastro

Posted on

Docker Concept

  1. What is Docker and why is it used? Docker is an operating system for containers. It is use to build, start, or stop containers.
  2. What is a Docker image and how is it different from a Docker container? A Docker image is a template that defines how a container will be realized. A Docker container is a runtime instance of a Docker image.
  3. How do you create a Docker image and run a Docker container?
    How to Create Docker Image >
    Create a Base Container > Inspect Images > Inspect Containers

    Start the Container > Modify the Running Container > Create
    an Image From a Container > Tag the Image > Create Images
    with Tags
    How to run Docker Container
    Get the sample application. If you have git, you can clone
    the repository for the sample application > Explore the
    Dockerfile > Build your first image > Run your container >
    Verify that your container is running.

  4. What is a Dockerfile and how do you use it to create a Docker image?
    A Dockerfile is simply a text-based file with no file extension that contains a script of instructions. Docker uses this script to build a container image. In the app directory, the same location as the package.json file, create a file named Dockerfile .

  5. How can you inspect the contents of a Docker container and the changes made to a container while it was running?

  6. How can you share a Docker image with others and pull an image from a Docker registry?
    To pull the Docker image from a private registry, users are required to start the registry container. Then, log in to the private registry. After that, utilize the “docker pull ” command to pull the Docker image from Docker private registry.

  7. What are the different network modes available in Docker and how do you choose the right network mode for your application?
    Bridge mode
    Host mode
    Container mode
    No networking

  8. How can you mount a volume in a Docker container and share data between the host and container?
    You can mount host volumes by using the -v flag and specifying the name of the host directory.

  9. What is the difference between a Docker Compose file and a Dockerfile, and how are they used in deploying multi-container applications?
    The key difference between the Dockerfile and docker-compose is that the Dockerfile describes how to build Docker images, while docker-compose is used to run Docker containers.

  10. How can you monitor the performance of a Docker container and diagnose issues with it?
    ** You can use the docker stats command to live stream a
    container's runtime metrics. The command supports CPU, memory
    usage, memory limit, and network IO metrics. The docker stats
    reference page has more details about the docker stats

  11. Components of Docker and its Brief Summary
    The basic components include Docker client, Docker image, Docker Daemon, Docker Networking, Docker registry, and Docker container, whereas Docker Compose and Docker swarm are the advanced components of Docker.

  12. What is the difference between docker pause and unpause?
    The main difference between the paused and stopped states is
    that the memory portion of the state is cleared when a
    container is stopped, whereas, in the paused state, its
    memory portion stays intact.

  13. What is the difference between docker stop and kill?
    This means the difference between docker stop and docker
    kill is that - stop can allow safe termination (within the
    grace period) while kill terminates immediately. A container
    that is in the created state or stopped can be removed with
    docker rm.

  14. What is the difference between docker exec and attach?
    ** When you run an exec, it will basically spins up a new
    process inside the container whereas attach basically lets
    you attach to an existing process inside the container.**

  15. List of dockerfile instructions and its Brief Summary?
    User - Change user & group membership
    Copy - Copy directories and files to the image
    Add - Copy directories and files to the image
    Run - Carry out the command in image in the course of build process

  16. What is the difference between CMD vs Entry
    The main difference between CMD and ENTRYPOINT in Docker is that execution-wise, the default arguments provided by CMD can get overridden, whereas those provided by ENTRYPOINT cannot.

Top comments (0)