Showing posts with label cmd. Show all posts
Showing posts with label cmd. Show all posts

Sunday, September 8, 2019

docker cheat sheets

https://github.com/wsargent/docker-cheat-sheet


About "docker inspect". you can inspect a container or an image.


docker inspect $containerid

-> there are 2 places with "Image", one showing the image's sha2, the other the image's name.
If you use the sha2 to identify the image, remember it's truncated to the leftmost 12 digits.

docker image inspect $imagename (or $imagesha2)

here you find the Cmd and Entrypoint`


You can assign a label to image in Dockerfile:
LABEL app=hello-world

and use it to filter:

docker images --filter "label=app=hello-world"


since version 18.6 you can use BuildKit https://docs.docker.com/engine/reference/builder/#label :

without BuildKit:

docker build -t myhw .
Sending build context to Docker daemon  9.728kB
Step 1/3 : FROM busybox:latest
 ---> db8ee88ad75f
Step 2/3 : CMD echo "Hello world date=" `date`
 ---> Using cache
 ---> 22bd2fd85b95
Step 3/3 : LABEL app=hello-world
 ---> Running in 1350a308f4eb
Removing intermediate container 1350a308f4eb
 ---> 7a576b758d86
Successfully built 7a576b758d86
Successfully tagged myhw:latest


export DOCKER_BUILDKIT=1


with BuildKit:

docker build -t myhw .
[+] Building 2.2s (5/5) FINISHED                                                                                                                                                                                   
 => [internal] load .dockerignore                                                                                                                                                                             1.5s
 => => transferring context: 2B                                                                                                                                                                               0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                          1.2s
 => => transferring dockerfile: 181B                                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/busybox:latest                                                                                                                                             0.0s
 => [1/1] FROM docker.io/library/busybox:latest                                                                                                                                                               0.0s
 => => resolve docker.io/library/busybox:latest                                                                                                                                                               0.0s
 => exporting to image                                                                                                                                                                                        0.0s
 => => exporting layers                                                                                                                                                                                       0.0s
 => => writing image sha256:4ce77b76b309be143c25ad75add6cdf17c282491e2966e6ee32edc40f802b1f4                                                                                                                  0.0s
 => => naming to docker.io/library/myhw     



CMD vs ENTRYPOINT

if you use
ENTRYPOINT echo "pippo "
docker build -t echopippo .
docker run echopippo

it will print "pippo"

if you use also CMD
ENTRYPOINT echo "pippo "
CMD " peppo"

it will still print only "pippo". To append arguments, you must use the JSON array format (i.e. square brackets)

ENTRYPOINT ["echo", "pippo "]
CMD [" peppo"]


this will print "pippo peppo".

If you provide an extra parameter from command line:
docker run echopippo pluto

then CMD is ignored, and the parameter from command line is used:
pippo pluto




Priceless Romin Irani turorial on :

docker volumes: https://rominirani.com/docker-tutorial-series-part-7-data-volumes-93073a1b5b72

Dockerfile: https://rominirani.com/docker-tutorial-series-writing-a-dockerfile-ce5746617cd


Other tutorials here https://github.com/botchagalupe/DockerDo






Wednesday, October 28, 2015

no more stinky cmd prompt in Windows: use cmder instead!

http://cmder.net/

Download the "full" edition from https://github.com/cmderdev/cmder/releases . Unzip. Run cmder.

If you install the version from the main page you get a "api-ms-win-crt-runtime-l1-1-0.dll missing" error.

It looks definitely more feature-rich than the STINKY cmd prompt from Windows.

Sunday, October 2, 2011

Saturday, September 3, 2011

Struggling with CMD files on Windows

Since the old times of DOS, the MS scripting syntax has been probably one of the most pathetic and horrendous pieces of shit I have ever seen in my life.
Bat files, cmd files, all pathetic spaghetti mess full of GOTO and with cryptic error messages.
Unix shell scripts for all that matters are not a lot better, but slightly better yes they are.

Now I have to perform a "jar tvf" on all jars in a directory.

The only way I could do it is:

dir /b *.jar > alljars.txt


@echo off
echo > allfilesinjars.txt
FOR /F %%G IN (alljars.txt) DO (
@echo %%G >> allfilesinjars.txt
jar tvf %%G >> allfilesinjars.txt
@echo "______________________" >> allfilesinjars.txt
)


(see http://ss64.com/nt/for_f.html for help)

It's crap but it works.

So any time I need a class, I just search it in the txt file instead of doing costly searches in the jars.