Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

README.md

dt (docker-tool)

logo

It is a convenient tool for many Docker operations.

    __              __                      __                __
.--|  |.-----.----.|  |--.-----.----.______|  |_.-----.-----.|  |
|  _  ||  _  |  __||    <|  -__|   _|______|   _|  _  |  _  ||  |
|_____||_____|____||__|__|_____|__|        |____|_____|_____||__|

dt (docker-tool)

Usage:
sudo ./docker-tool <action> [args...]

Actions:
  clean-img                        | Clean dangling images
  clean-vol                        | (DANGEROUS!!!) Clean dangling volumes, who are not referenced by any containers
  clean-container                  | Remove exited containers
  img [name]                       | Grep image by given <name>
  logs <container-id/name>         | == docker logs --tail=50 -f <container-id/name>
  net <container-id/name>          | Show network info (mode, veth pair, ...) of a container
  ns-net <container-id/name>       | Enter the net namespace of a container, with all host's tools available. Use "exit" to exit
  pid <container-id/name>          | Get the pid of a container
  ps [-a] [name]                   | Grep from docker ps
  run ...                          | == docker run -it --rm ...
  ssh <container-id/name or image> | Enter the bash/sh of a container or image
  config [-l|--list] <key> <value> | config docker-tool, save under /etc/docker-tool/ (available keys: tag-prefix)
                                   |   '-l', '--list' to show all the current configurations.
  tag [-p] [--rm] <image>          | tag the image by configured prefix.
                                   |   '-p' to push the new image after tagging it.
                                   |   '--rm' to remove the new local image after pushing it. (must use --rm with -p)

Other actions:
  clean-k8s                        | Clean dangling k8s containers
  self-upgrade                     | Upgrade "docker-tool" to the latest version

Installation

INSTALL_DIR='/usr/local/bin'
sudo curl -o ${INSTALL_DIR}/docker-tool https://raw.githubusercontent.com/ohmystack/docker-tool/master/docker-tool
sudo chmod a+x ${INSTALL_DIR}/docker-tool
sudo ln -sf ${INSTALL_DIR}/docker-tool ${INSTALL_DIR}/dt

You can use command-line docker-tool or dt for short.

Upgrade:

dt self-upgrade

Key Features

"ssh" into a container or an image easily

  • dt ssh

This is not a real "ssh", but most users want such kind of experience.

It is complicated to do this without this tool, you will type docker exec -it xxx /bin/bash, and then find that there is no bash in the container, then change to sh. Or, type docker run -it --rm --entrypoint /bin/bash xxx to get into an image.

dt ssh <image>

dt-ssh-image

dt ssh <container>

dt-ssh-container

Search

  • Images: dt img
dt img <keyword>
  • Containers: dt ps
dt ps <keyword>
dt ps -a <keyword>

Short-cut for docker commands

  • dt logs

Short for docker logs --tail=50 -f <container-id/name>.

dt logs <container-name>
  • dt pid

Get the pid of a container.

dt pid <container-name>

Clean

  • dt clean-img

Clean the dangling images. May save lots of your disk space.

  • dt clean-container

Clean the exited containers.

  • dt clean-vol

Clean the dangling volumes.

Network

  • dt net

Get the network type and info.
You can even get the veth pair info of a container if it is using the "default" NetworkMode. This is very helpful when debugging the network.

dt-net-default dt-net-host

  • dt ns-net

Enter the network namespace of a container.
So that you can use the utils installed on your server to debug the container inside network.

dt-ns-net

Development

If you have any good ideas about docker-tool, welcome to submit your PRs.

One simple rule: Keep this docker-tool a single file bash program.

@ohmystack

About

Convenient tool for Docker operations

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.