10 unpopular Dcoker tricks

In ordinary learning, docker has a lot of contact. In addition to frequently used commands such as docker run and docker stop, docker also has many very useful but infrequently used commands. Here is a summary:

  1. docker top CONTAINERID

This command is used to view process information in a container. For example, when you want to view several nginx processes in an nginx container, you can do this:

  1. docker load && docker save

I generally use these two commands to download and package the image of Kubernetes, because you know that the domestic network speed is not as fast as abroad.

  1. docker search

This command can help you easily search for images in DockerHub from the command line, such as:

  1. docker events

This command can help you get real-time information about various events of docker, such as creating a container. Description of
common parameter
OPTIONS:

-f: filter events according to conditions;

--Since: show all events after the specified timestamp;

--Until: The running time is displayed until the specified time;

  • Other information can be filtered by specifying the ID of the container. The events related to the container are: attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart , Start, stop, top, unpause, update
docker events -f container=<name or id>
  • Other information can be filtered by specifying the image ID. The events related to the image are: delete, import, load, pull, push, save, tag, untag
docker events -f image=<tag or id>
  • You can filter other information by specifying the volume ID, and volume-related events are: create, mount, unmount, destroy
docker events -f volume=<name or id>
  • Other information can be filtered by specifying the network ID. Network-related events are: create, connect, disconnect, destroy
docker events -f network=<name or id>
  • If the specified time is in seconds, you need to convert the time to a timestamp. If the time is a date, you can use it directly, such as –since=“2016-07-01”.
  1. docker update CONTAINERID

When you run docker run, you find that some parameters are not in the state you want. For example, the nginx container cpu you set or the memory is too small, at this time you can use docker update to modify these parameters.

  1. Docker history
    can use this command when you modify a mirror but forget the modification commands for each layer, or you want to see how a mirror is built.

  2. docker wait CONTAINERID

This command can view the exit status of the container, you can know whether the container exited normally or abnormally

  1. docker pause && docker unpause

When you run a container but want to pause it, you can use this command.

  1. docker diff CONTAINERID

You can use this command when you run a container, but you don't know which files have been modified in the container.
This command can track the following three changes:
A file or directory is created
D file or directory is deleted
C file is modified Or catalog

Insert picture description here

  • Since the docker diff command compares the container with the image that created the container,
  1. docker stats

This is the built-in monitoring command of docker. You can use this command when you want to view the memory and cpu usage of all containers under the current host.

Guess you like

Origin blog.csdn.net/qq_44891295/article/details/109440824