Wednesday, September 24, 2025

Docker Cheatsheet 2025

Docker cheatsheet 2025

Test with hello-world

$ docker run hello-world

$ ps -A | grep dockerd
=> dockerd

Run or download

$ docker run busybox echo "hello world"
$ docker run -it busybox echo /bin/sh
# -p <host>:<container> portmap eg. -p 8080:8080
# -v, map volume

Container and image

# check container
$ docker container ps -a

$ docker stop <container id>

# remove all container
$ docker container prune

$ docker image ls
$ docker image ls -q # quiet, id only

remove image

$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest 0ed463b26dae 11 months ago 4.43MB
$ docker rmi busybox:latest # OR
$ docker rmi <image id>

remove all image

$ docker rmi $(docker image ls -q)

Install: Linux

Note: remove previous version before install
$ sudo systemctl stop docker
$ dpkg -l | grep "docker\|containerd.io"

Install
$ curl -fsSL test.docker.com -o get-docker.sh && sh get-docker.sh

Install: macOS homebrew

$ brew install colima ## need lima, qemu etc.
$ brew install docker docker-compose
## OR
$ brew install colima docker lima-additional-guestagents

$ colima start | stop [default]

Wednesday, September 17, 2025

Received the Raspberry Pi Pico 2W

Received the Raspberry Pi Pico 2W

I just received the Raspberry Pi Pico 2 this morning, after a long weekend. I was occupied today and unable to test it after I received it.

The Raspberry Pi Pico is small, slightly smaller that what I was expecting.

It suppose to be easy to install with Micropython. Plug in the power/USB with Bootsel button pressed, the Pico will appeared as an USB drive, just copy the Micropython UF2 file to the Pico(drive) and reboot.

Wednesday, September 10, 2025

Docker Tutorial 2025 Part 1

Docker Tutorial 2025 Part 1

This is a quick and dirty tutorial for Docker

What is docker?

Docker is a container, a lightweight vm to run linux os environment. It use lesser (much lesser) resource than Virtualbox. Docker can be used for development and production, it provide consistant environment, and more secure.

Docker can run on Linux, macOS (Docker Desktop) and Windows (WSL2).

Install

Linux

So far using the script is easiest, it even works on Chrome OS constini vm. Before install using the script, remove the previous version as advised.

# eg. for debian, check for dpkg -l | grep "docker\|container.io", remove those softwares
$ curl -fsSL test.docker.com -o get-docker.sh && sh get-docker.sh

macOS (brew colima)

I use colima (+lima +qemu), as a replacement of Docker Dekstop for macOS.
$ brew install colima
$ colima start # it may takes some time to start colima

To test docker is working:
$ docker run hello-world
=>Hello from Docker!

Note: You may need root/sudo to run.

Image and container

Docker image is a pre-build image ready to be run, it can be downloaded from docker hub, modified and update back to the docker hub. A container is a running vm base on the docker image.

# docker pull image:tag
$ docker pull busybox:latest
$ docker run busybox:latest
# OR
$ docker run busybox # if will add the tag:latest and download from docker hub
=> (nothing)

Nothing shown because this image doesn't output any message by default.

$ docker run busybox echo Hello, world
=> Hello, world

Image

Image name and tag can be found on hub.docker.com.
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest 0ed463b26dae 11 months ago 4.43MB

You can remove the image by:
# docker rmi image_id/image_name
$ docker rmi 0ed463b26dae
=> unable to remove repository ... container 347423e07780 is using

It is ok you can not delete the image, as container is using it.

Container

$ docker run -it busybox /bin/sh # -it, interactive tty??
busybox# echo "hello, world" >/hello
busybox# exit

# if you run the command again, cant find the file /hello.txt
$ docker run -it busybox ls /hello.txt
ls: /hello: No such file or directory

That is because every time you execute the command it created a new container. The file still exist in the earlier container.

$ docker container ps -a
ea9066a4d753 busybox "ls /hello" ... tender_shaw
86d9045d5cab busybox "/bin/sh" ... kind_maxwell

The container has a unique id and a unique random name. The file hello is at the container kind_maxwell. Since the status is Exited, need to start the container to access the file again.

$ docker container start kind_maxwell # OR simply docker start kind_maxwell
$ docker exec kind_maxwell cat /hello.txt
hello, world

Delete container and image

$ docker container ps -a
You can delete one by one, or delete all.
$ docker container prune
# stop container
$ docker [container] stop id

Now you can delete the image:
$ docker rmi busybox
...
# delete all
$ docker rmi $(docker image ls -q) # -q, quiet, just list the image id

Start container with specific name

$ docker run --name kind_maxwell busybox
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
$ docker ps -a | grep kind_maxwell
ee044ad46bf2 busybox:latest Exited (0) kind_maxwell

Wednesday, September 03, 2025

Let's Try Jvm-pico

Let's try jvm-pico

Basically J2ME/PhoneMe is dead, like J2EE, but worst. Just sharing, because I am a strong supporter of Java...

Yesterday I found a J2ME vm which can run on Raspberry Pi Pico (a very small microcontroller). This guy name Oren Sokoler, I think just he himself alone ported the PhoneMe to Pico, name pico-jvm (https://github.com/orenskl/pico-jvm), not completed, but seems like hello world is working. Not working for production yet, good for research.

Sun microsystem open source Java before Sun acquired by Oracle, that is a right move, or else Java could be half dead now. There are many Java VM/JDK by other companies including Microsoft and Amazon, I believe all based on the OpenJDK from Sun.

Sun open source their OS Solaris as well, but not so pupular as Linux. Is not easy to write an OS kernel or VM as an open source project. A good example is GNU Hurd kenel, everything is ready just without a working kernel.

Another example is ELKS (Linux on 16 bits 8086), even though is still on going, but not ready for production yet. It doesn't attract enoutgh developers to join as compare to Linux.

I just hope pico-jvm can be continued until becomes a beta product or even further.