Code Monkey home page Code Monkey logo

commando's Introduction

Commando

Version

Commando generates Docker images on-demand with all the commands you need and simply point them by name in the docker run command. Commando is SysOps and DevOps best friend.

Features

When running a Docker image you will enter the Bash shell by default and have the requested commands available.

Commando is deployed under cmd.cat and publicly available, you can freely use it but do not depend on it's stability in your projects as it is hosted on my private server with limited resources.

The image is based on Alpine and the builder does its best to reuse the existing layers when using multiple commands. This way both cmd.cat/envsubst/curl and cmd.cat/curl/envsubst are the same images, also cmd.cat/envsubst/tcpdump/curl adds only one extra layer.

Source: Linux PerfTools

# One command.
docker run -it cmd.cat/strace
docker run -it cmd.cat/ab

# Two...
docker run -it cmd.cat/curl/wget
docker run -it cmd.cat/htop/iostat

# ... or a lot of commands, how many you need.
docker run -it cmd.cat/ping/nmap/whois
docker run -it cmd.cat/ngrep/tcpdump/ip/ifconfig/netstat

Use the generated image with host/container pid/network modes to debug and monitor your containers or the host system.

docker run -d --name nginx nginx

# Enter the shell with all network tools available
docker run -it --net container:nginx cmd.cat/curl/ab/ngrep
# Monitor all network interfaces of the nginx container
docker run -it --net container:nginx cmd.cat/ngrep ngrep -d any
docker run -d --name redis redis

# Monitor the processes running inside the redis container
docker run -it --pid container:redis cmd.cat/htop htop
# Monitor network and processes on the host system
docker run -it --net host --pid host cmd.cat/htop/ngrep

Running

Run the project locally or deploy it internally inside your company with a single command that will pull all the required images and build the registry proxy:

git clone https://github.com/lukaszlach/commando.git
cd commando
docker-compose up -d

Run any command built locally the same way:

docker run -it localhost:5050/tcpdump
docker run -it localhost:5050/strace/php

The first run needs to build the base image so it takes longer than all further calls.

License

MIT License

Copyright (c) 2019 Łukasz Lach [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Google Nixery ❤️

commando's People

Contributors

lukaszlach avatar lukaszlach-arch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

commando's Issues

webp tools missing in image

Hello, stumbled upon this great project because I needed https://developers.google.com/speed/webp/docs/webpinfo .

I found it via https://command-not-found.com/webpinfo which I understand is a related project if Commando. And I think this issue lies probably more within that side of things, based on what I read in #3. But I have found no way to report it on that site.

Whichever of the WebP tools I try to install I get only a container with libwebp, but no actual runnable command (afaik), for example:

$ docker run --rm -it cmd.cat/webpinfo bash
Unable to find image 'cmd.cat/webpinfo:latest' locally
latest: Pulling from webpinfo
97518928ae5f: Already exists 
855023b9a688: Already exists 
dbc368251d6c: Already exists 
38360df80cbc: Pull complete 
Digest: sha256:68fbef4cd650be3eecfe408dc093bc570727c6793847b99e17a6afc2d986029f
Status: Downloaded newer image for cmd.cat/webpinfo:latest
bash-5.1# webpinfo
bash: webpinfo: command not found
bash-5.1# apk list | grep webp
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/main: No such file or directory
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/community: No such file or directory
libwebp-1.2.0-r2 x86_64 {libwebp} (BSD-3-Clause) [installed]

If I install libwebp-tools i get all the relevant commands:

bash-5.1# apk add libwebp-tools
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/4) Installing giflib (5.2.1-r0)
(2/4) Installing libjpeg-turbo (2.1.0-r0)
(3/4) Installing libpng (1.6.37-r1)
(4/4) Installing libwebp-tools (1.2.0-r2)
Executing busybox-1.33.1-r6.trigger
OK: 12 MiB in 28 packages
bash-5.1# webpinfo
Usage: webpinfo [options] in_files
Try -longhelp for an exhaustive list of options.
bash-5.1# cwebp
Usage:

   cwebp [options] -q quality input.png -o output.webp

where quality is between 0 (poor) to 100 (very good).
Typical value is around 80.

Try -longhelp for an exhaustive list of advanced options.
bash-5.1# apk list | grep webp
libwebp-doc-1.2.0-r2 x86_64 {libwebp} (BSD-3-Clause)
libwebp-tools-1.2.0-r2 x86_64 {libwebp} (BSD-3-Clause) [installed]
libwebp-1.2.0-r2 x86_64 {libwebp} (BSD-3-Clause) [installed]
libwebp-static-1.2.0-r2 x86_64 {libwebp} (BSD-3-Clause)
libwebp-dev-1.2.0-r2 x86_64 {libwebp} (BSD-3-Clause)

So as stated above, I think the installation instructions are incorrect, which then causes the image being built incorrectly. Hope my investigation will help :)

Broken API with `command-not-found.com`

Recently I have noticed some queries to cmd.cat does not work as expected. After evaluating the error and digging into the design, I figured out the install.sh script in the images is not working properly. Going further, I noticed it is because queries of the form curl -sSfL "https://command-not-found.com/-/api/package/alpine/$COMMAND" do not return a string anymore, but a full web-page that makes the whole code broken. I could not find the public API of the website to come up with a fix by myself, but I'd like to ask you to fix the command-not-found.com API back to its previous stage, so cmd.cat becomes operational again. Thanks for your amazing code.

chsh missing

root@OpenWrt ~# docker run -it cmd.cat/chsh chsh
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"chsh\": executable file not found in $PATH": unknown.
ERRO[0001] error waiting for container: context canceled

root@OpenWrt ~ [127]# docker run -it cmd.cat/chsh
bash-5.0# find / -name "chsh"
bash-5.0#

😥

Support other/edge Alpine versions

Newly generated images are always (implicitly) based on :latest - the FROM base image specifies just alpine. It would be complementary (well, quite neat) if we could use the tag specified on cmd.cat/[...]:${tag} to change the base.

Perhaps not necessarily fully parameterize it, but at least add support for :edge to use FROM alpine:edge as base. 🌻

How to start persistent "tool" container with docker-compose?

I tried to set up a little tool-container with tools from cmd.cat to not having to install them on my host machine. But since I want to install and update them with docker-compose and keep the container running I set up my docker-compose file like this:

version: "3.8"
services:
  tools:
    image: cmd.cat/curl/wget
    container_name: tools
    volumes:
      - "/my_volume:/internal_volume"
    restart: unless-stopped

the command:
docker-compose pull tools && docker-compose up -d
runs through smooth, but then the container keeps on restarting and ends up in a restart loop:

docker exec -it tools /bin/bash
Error response from daemon: Container 4b4af273627611a793715af4c96d43xxxxxxxxxxxxxxxxxxxxxxxxx is restarting, wait until the container is running

Is there any good way, to run these cmd.cat tools in a persistent container so I don't have to start them with docker run -it everytime I want to use them?
Thanks in advance!

Can't install some tools that do exist in alpine packages

e.g.:

docker run -it cmd.cat/httpie
Unable to find image 'cmd.cat/httpie:latest' locally
/nix/store/zbppgrbn7lsz51dkswmh1gdfrv52rjk9-docker-19.03.8/libexec/docker/docker: Error response from daemon: error parsing HTTP 400 response body: invalid character 'c' looking for beginning of value: "curl: (22) The requested URL returned error: 404 Not Found\nSending build context to Docker daemon  4.143kB\r\r\nStep 1/5 : FROM alpine AS release\n ---> f70734b6a266\nStep 2/5 : CMD [\"/bin/bash\"]\n ---> Using cache\n ---> 74e19f02b758\nStep 3/5 : RUN apk --no-cache add bash curl\n ---> Using cache\n ---> 2a1694a8929c\nStep 4/5 : COPY install.sh /\n ---> Using cache\n ---> 57d535599a7d\nStep 5/5 : RUN bash /install.sh httpie\n ---> Running in 351dda98de96\n\x1b[91mWARNING: Ignoring APKINDEX.70f61090.tar.gz: No such file or directory\nWARNING: Ignoring APKINDEX.ca2fea5b.tar.gz: No such file or directory\n\x1b[0mError: Nothing to install\nRemoving intermediate container 351dda98de96\nThe command '/bin/sh -c bash /install.sh httpie' returned a non-zero code: 1\n".
See '/nix/store/zbppgrbn7lsz51dkswmh1gdfrv52rjk9-docker-19.03.8/libexec/docker/docker run --help'.

From a running container:

docker run -it cmd.cat/curl/wget

bash-5.0# 
bash-5.0# bash /install.sh httpie
WARNING: Ignoring APKINDEX.70f61090.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.ca2fea5b.tar.gz: No such file or directory
Error: Nothing to install
bash-5.0# apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.6-42-ge8abc3bd90 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.6-40-g4ab6ec338e [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11270 distinct packages available
bash-5.0# bash /install.sh httpie
Error: Nothing to install

Unable to use commando deployed locally

Tried to deploy and use commando local instance according to dockermasters devops path.
It failed.

Part of the log with response, fixed only line endings

docker: Error response from daemon: error parsing HTTP 400 response body: invalid character 'c'     looking for beginning of value: "curl: (22) The requested URL returned error: 404 Not Found
Sending build context to Docker daemon  4.143kB\r\r
Step 1/5 : FROM alpine AS release
---> 9c6f07244728
Step 2/5 : CMD [\"/bin/bash\"]
---> Using cache
---> f8dbf69b173f
Step 3/5 : RUN apk --no-cache add bash curl
---> Running in 4b1ed815bcc4
cgroups: cgroup mountpoint does not exist: unknown

Please see full log below.

❯ docker compose build
[+] Building 1.3s (17/17) FINISHED
 => [internal] load build definition from Dockerfile                                                                     0.0s
 => => transferring dockerfile: 742B                                                                                     0.0s
 => [internal] load .dockerignore                                                                                        0.0s
 => => transferring context: 34B                                                                                         0.0s
 => [internal] load metadata for docker.io/library/golang:1.13-alpine                                                    1.2s
 => [internal] load metadata for docker.io/library/alpine:3.10                                                           0.0s
 => [auth] library/golang:pull token for registry-1.docker.io                                                            0.0s
 => [builder 1/4] FROM docker.io/library/golang:1.13-alpine@sha256:e74b83b94d499cb34c7edf55fbdff9d3cfabd238a35f9cb1b59d  0.0s
 => [docker 1/2] FROM docker.io/library/alpine:3.10                                                                      0.0s
 => [internal] load build context                                                                                        0.0s
 => => transferring context: 224B                                                                                        0.0s
 => CACHED [release 2/5] RUN apk --no-cache add curl bash                                                                0.0s
 => CACHED [builder 2/4] WORKDIR /builder                                                                                0.0s
 => CACHED [builder 3/4] COPY ./builder /builder                                                                         0.0s
 => CACHED [builder 4/4] RUN go build .                                                                                  0.0s
 => CACHED [release 3/5] COPY --from=builder /builder/builder /usr/local/bin/                                            0.0s
 => CACHED [docker 2/2] RUN apk --update add curl &&     mkdir /docker &&     curl -sSfL "https://download.docker.com/l  0.0s
 => CACHED [release 4/5] COPY --from=docker /usr/local/bin/docker /usr/local/bin/                                        0.0s
 => CACHED [release 5/5] COPY ./builder /builder                                                                         0.0s
 => exporting to image                                                                                                   0.0s
 => => exporting layers                                                                                                  0.0s
 => => writing image sha256:e3b3b9b0e399d3c03dc3828789d774a3dbd476ea84dcda09c59b9335af5ca55d                             0.0s
 => => naming to docker.io/library/commando_builder                                                                      0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

~/projects/OTHER/dockermasters/devops/commando/commando master ──────────────────────────────────────────────────────────────
❯ docker compose up -d
[+] Running 4/4
 ⠿ Network commando_default    Created                                                                                   0.0s
 ⠿ Container builder_registry  Started                                                                                   0.5s
 ⠿ Container builder_docker    Started                                                                                   0.5s
 ⠿ Container builder           Started    

~/projects/OTHER/dockermasters/devops/commando/commando master ──────────────────────────────────────────────────────────────
❯ docker run -it localhost:5050/tcpdump
Unable to find image 'localhost:5050/tcpdump:latest' locally
docker: Error response from daemon: error parsing HTTP 400 response body: invalid character 'c' looking for beginning of value: "curl: (22) The requested URL returned error: 404 Not Found\nSending build context to Docker daemon  4.143kB\r\r\nStep 1/5 : FROM alpine AS release\nlatest: Pulling from library/alpine\n213ec9aee27d: Pulling fs layer\n213ec9aee27d: Verifying Checksum\n213ec9aee27d: Download complete\n213ec9aee27d: Pull complete\nDigest: sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad\nStatus: Downloaded newer image for alpine:latest\n ---> 9c6f07244728\nStep 2/5 : CMD [\"/bin/bash\"]\n ---> Running in 70eaf3d765db\nRemoving intermediate container 70eaf3d765db\n ---> f8dbf69b173f\nStep 3/5 : RUN apk --no-cache add bash curl\n ---> Running in 17e16ef0e6a1\nRemoving intermediate container 17e16ef0e6a1\ncgroups: cgroup mountpoint does not exist: unknown\n".
See 'docker run --help'.

~/projects/OTHER/dockermasters/devops/commando/commando master ────────────────────────────────────────────────────── ✘ 125 4
❯ docker run -it localhost:5050/tcpdump
Unable to find image 'localhost:5050/tcpdump:latest' locally
docker: Error response from daemon: error parsing HTTP 400 response body: invalid character 'c' looking for beginning of value: "curl: (22) The requested URL returned error: 404 Not Found\nSending build context to Docker daemon  4.143kB\r\r\nStep 1/5 : FROM alpine AS release\n ---> 9c6f07244728\nStep 2/5 : CMD [\"/bin/bash\"]\n ---> Using cache\n ---> f8dbf69b173f\nStep 3/5 : RUN apk --no-cache add bash curl\n ---> Running in 4b1ed815bcc4\nRemoving intermediate container 4b1ed815bcc4\ncgroups: cgroup mountpoint does not exist: unknown\n".
See 'docker run --help'.

❯ docker --version
Docker version 20.10.17, build 100c701

~/projects/OTHER/dockermasters/devops/commando/commando master ──────────────────────────────────────────────────────────────
❯ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

allow adding dependencies by package name

I am trying to use the command po4a-gettextize which has no hard dependency on perl-yaml-tiny, but I do need that dependency for my use case.
I have found no way to add that package, as it does not expose any command.
It would be nice to have a way to add packages to an image, either by falling back to using the input as a package name or by some kind of prefix.

So, either
docker pull cmd.cat/po4a-gettextize/perl-yaml-tiny
should automatically handle perl-yaml-tiny as a package name, as it does not get any result from the command-not-found API
OR
use e.g.
docker pull cmd.cat/po4a-gettextize/@perl-yaml-tiny,
using @ as an explicit decorator for package names.

htop & top does not work on OSX & Rasbian

macOS 10.13.6 (17G8037)
docker --version ?1 8:22:27
Docker version 19.03.5, build 633a0ea

docker run cmd.cat/htop htop                                                                                              √ 8:22:16
Error opening terminal: unknown.

Raspbian GNU/Linux 10 (buster)
docker --version
Docker version 19.03.5, build 633a0ea

docker run cmd.cat/htop htop                                                                                                                                         
standard_init_linux.go:211: exec user process caused "exec format error"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.