Click on the image to see the best articles of the past two years  


Here are the five tools I recommend.

Watchtower:
Automatically updates the Docker container

Watchtower monitors running containers and monitors any changes to their images when they are initially started. When Watchtower detects that an image has changed, it automatically restarts the container with the new image. I wanted to try out the latest build image in my local development environment, so I used it.

Watchtower itself is packaged as a Docker image, so you can run it just like any other container. To run Watchtower, you need to execute the following command:

$ docker run -d --name watchtower --rm -v /var/run/docker.sock:/var/run/docker.sock v2tec/watchtower --interval 30Copy the code

In the command above, we start the Watchtower container with a mount file called /var/run/docker.sock. This is necessary so that Watchtower can interact with the Docker daemon API. We pass 30 seconds to the interval option. This option defines the polling interval for Watchtower. Watchtower supports more options that you can use as described in the documentation.

We now launch a container that Watchtower can monitor.

$ docker run -p 4000:80 --name friendlyhello shekhargulati/friendlyhello:latestCopy the code

Watchtower will now begin gently monitoring the FriendlyHello container. When I push a new image to the Docker Hub, Watchtower will detect a new available image on subsequent runs. It will gracefully stop that container and start the container with the new image. It will pass the options we passed to the run command earlier. In other words, the container will still start with the 400:80 publishing port.

By default, Watchtower will poll the Docker Hub registry for updated images. Watchtower can be configured to poll private registries by passing registry credentials in the environment variables REPO_USER and REPO_PASS.

To learn more about Watchtower, you are advised to read the Watchtower documentation

https://github.com/v2tec/watchtower/blob/master/README.md

Making address:

https://github.com/v2tec/watchtower

Docker-gc: Garbage collection of containers and images

The Docker-GC tool helps you clean up Docker hosts by removing unnecessary containers and images. It deletes all containers that have existed for more than an hour. In addition, it removes images that do not belong to any indent containers.

You can use docker-GC as a script and container. We will run docker-GC as a container. To use docker-GC to find all containers and images that can be deleted, run the following command:

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -eDRY RUN=1 spotify/docker-gcCopy the code

Sock file is loaded so that docker-GC can interact with the Docker API. We passed an environment variable DRY_RUN=1 to find containers and images to be deleted. If this parameter is not provided, docker-GC removes all containers and images. It is best to confirm in advance what docker-GC will delete. The output of the above command is as follows:

[2017-04-28T06:27:24] [INFO] : The following container would have been removed 0c1b3b0972bb792bee508 60c35a4 bc08ba32b527d53eab173d12a15c28deb931/vibrant_ yonath[2017-04-28T06:27:24] [INFO] : The following container would have been removed 2a72d41e4b25e2782f7844e188643e395650a9ecca660e7a0dc2b7989e5acc28 /friendlyhello_ web[2017-04-28T06:27:24] [INFO] : The following image would have been removed sha256:00f017a8c2a6e1 fe2f fd05c281 f27d069d2a99323a8cd514dd35f228ba26d2ff[busybox: latest][2017-04-28T06:27:24] [ INFO] : The following image would have been removed sha256 :4a323b466a5ac4ce6524 8dd970b538922c54e535700cafe9448b52a3094483ea[hello-world:latest][2017-04-28T06:27:24] [INFO] : The following image would have been removed sha256:4a323b4 66 a5ac4ce65248dd970b538922c54e535700cafe9448b52a3094483ea 2.7 slim] [python:Copy the code

If you agree with the Docker-GC cleanup scheme, you can run the docker-GC cleanup again without DRY_RUN.

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock spotify/docker-gcCopy the code

Docker-gc also supports a few other options. You are advised to read the Docker-GC documentation for more information:

https://github.com/spotify/docker-gc/blob/master/README.md

Making address:

https://github.com/spotify/docker-gc

Docker-slim: The miracle weight-loss drug for the container

If you’re worried about the size of your Docker image, the Docker-Slim can help.

The Docker-Slim tool uses static and dynamic analysis to slim down your bloated images. To use Docker-Slim, download the binary installation package for Linux or Mac from Github. Once it’s downloaded successfully, add it to your system variable PATH.

For example, I created a Docker image named FriendlyHello with the size of 194MB (as shown below) by referring to the official Docker document:

As you can see, for a simple application, we had to download 194 MB of data. Let’s use the Docker-Slim to see how much fat it can cut.

$ docker-slim build --http-probe friendlyhelloCopy the code

The Docker-Slim tool performs a series of checks and measures on the fat image to create a thin version of the image. Let’s take a look at the size of this weight loss.

As you can see, the mirror size has been reduced to 24.9 MB. You can start the container and it will behave the same way. The Docker-Slim tool supports Java, Python, Ruby, and Node.js applications.

Try it yourself and see how much you can lose. In my personal projects, I’ve found that it works in most situations. You can learn more about the Docker-Slim from its documentation:

https://github.com/docker-slim/docker-slim/blob/master/README.md

Making address:

https://github.com/docker-slim/docker-slim


Rocker: Breaking the limit of Dockerfile

Most developers using Docker use Dockerfile to build images. Dockerfile is a declarative method for defining all commands that a user can invoke on the command line to assemble an image.

Rocker Dockerfile instruction set (https://github.com/grammarly/rocker) is a new instruction. Grammarly created Rocker to solve their problems with the Dockerfile format.

The Grammarly team wrote an in-depth blog post explaining why they created it. I suggest you read it to better understand Rocker. In their post, they highlighted two issues:

  • Docker image size.

  • Slow build speed.

The blog also mentions some new instructions that Rocker has added. Refer to the Rocker documentation for all Rocker supported directives:

https://github.com/grammarly/rocker/blob/master/README.md

  • MOUNT is used to share volumes between builds so that they can be reused by dependency management tools.

  • There is already a FROM directive in Dockerfile. Rocker allows us to add more than one FROM directive. This means you can create multiple images from a single Rockerfile. The first set of instructions is used to build all of the product’s dependencies; The second set of instructions is used to build the product; This can greatly reduce the mirror size.

  • Tags are used to identify images at different stages of construction, which means you don’t have to TAG each image manually.

  • PUSH is used to PUSH an image to the mirror repository.

  • ATTACH lets you run the intermediate steps interactively. This is very useful for debugging.

To use Rocker, you must first install it on your machine. For Mac users, this is as simple as running a few brew commands:

$ brew tap grammarly/tap$ brew install grammarly/tap/rockerCopy the code

Once installed, you can use Rocker to build the image by passing in Rockerfile:

FROM python:2.7-slimWORKDIR/appadd. /appRUN PIP install -r requireties.txtexpose 80ENV NAME WorldCMD ["python","app.Py"]TAG shekhargulati/ friendlyhello:{{ .VERSION }}PUSH shekhargulati/friendlyhello:{{ .VERSION }}Copy the code

To build an image and push it to the Docker Hub, you can run the following command:

$rocker d build -- push-var version-1.0Copy the code

Making address:

https://github.com/grammarly/rocker

Ctop: The top-level interface of a container

Ctop is a tool I recently started using that provides a real-time metric view of multiple containers. If you are a Mac user, you can use brew installation as follows:

$ brew install ctopCopy the code

Once the installation is complete, you can start using CTOP. For now, you just need to configure the DOCKER_HOST environment variable.

You can run the ctop command to see the status of all containers.

To view only the running container, use the ctop -a command.

Ctop is a simple tool that is useful for understanding the containers running on your host. You can learn more about this in the CTOP documentation:

https://github.com/bcicen/ctop/blob/master/README.md

Making address:

https://github.com/bcicen/ctop

These are the 5 Docker tools I found useful. Do you use Docker tools in your daily work? I hope you find these tools helpful, and feel free to suggest any you find useful in the comments.

By Shekhar Gulati

Original: https://dzone.com/articles/5-docker-utilities-you-should-know

The latest 2TB technology dry goods: including system operation and maintenance, database, Redis, MogoDB, e-books, Java foundation course, Java practice project, architect comprehensive tutorial, architect practice project, big data, Docker container, ELK Stack, machine learning, BAT interview intensive video, etc. In the wechat public account dialog box reply keyword: 1024 you can get all the information.

Being is the END being

Excellent article recommendation:


Wechat PC edition major update! You can also play mini-games on your computer

Internet company project launch process

Server hacked? Don’t panic! Check out these five easy mistakes first!

CI/CD automatic deployment and use in Gitlab

Only know Baidu disk? These few people cloud storage better use!

When exactly is my Prometheus calling the cops?

Click [read article] to find out more

Click a look, forward to support it ↓↓ ↓