Skip to content
mwang0517 edited this page Dec 27, 2021 · 3 revisions

Why do you need docker?

  1. Compatibility/Dependency
  2. Long setup time
  3. Different Dev/Test/Prod environments

We need something that could help us with the above issue and something that will allow us to modify or change these components without affecting the other components and even modify the underlying operating system as required. With docker, we are able to run each component in a separate container with its own dependencies and its own libraries.

What are containers?

Containers are completely isolated environments, as in they have their processes or services or their network like virtual machines, except they share the same OS kernel.

Basic docker commands

  1. docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

    The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command.

  2. docker ps [OPTIONS]

    List containers.

  3. docker stop [OPTIONS] CONTAINER [CONTAINER...]

    The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. The first signal can be changed with the STOPSIGNAL instruction in the container’s Dockerfile, or the --stop-signal option to docker run.

  4. docker rm [OPTIONS] CONTAINER [CONTAINER...]

    Remove one or more containers.

  5. docker images [OPTIONS] [REPOSITORY[:TAG]]

    List images.

  6. docker rmi [OPTIONS] IMAGE [IMAGE...]

    Removes (and un-tags) one or more images from the host node. If an image has multiple tags, using this command with the tag as a parameter only removes the tag. If the tag is the only one for the image, both the image and the tag are removed.

  7. docker pull [OPTIONS] NAME[:TAG|@DIGEST]

    Pull an image or a repository from a registry.

  8. docker attach [OPTIONS] CONTAINER

    Use docker attach to attach your terminal’s standard input, output, and error (or any combination of the three) to a running container using the container’s ID or name. This allows you to view its ongoing output or to control it interactively, as though the commands were running directly in your terminal.