1. my scratchpad
  2. command / prompt description
    /var/lib/docker where are docker containers stored
    docker exec -it <container_name> sh open a shell into a running container (more)
    docker image ls list all docker images
    docker image rm removes an image from the host node — alias docker rmi
    docker rmi $(docker images -a -q) remove all locally installed Docker images
    docker image prune removes all dangling images (those with tag none). The -a option would also remove images that have no container
    docker ps -a list all containers, including the stopped ones — alias: docker container ls -(l)a
    docker container prune remove stopped containers
    docker logs container_id can be either the name or the identifier of the container. You can also use -f to follow
    systemctl status docker check the status of the docker deamon
    pgrep docker find the PID of the docker deamon
  3. some docker cheatsheets
  4. how to build the docker image and run the container for IACS'24'COGN
    1. cd into the /iacs-ui.24.cognitera/frontend directory so that you have the Dockerfile in the current directory
    2. Make sure the user is in the docker group (see the entry below)
    3. build the docker image with the --network host option and supply a plausible name:
      $ docker build --network host -t iacs-ui.24.cogn:v1 .
    4. if you want to keep and perhaps examine the logs of the docker build process use the following in lieu of the above command:
      docker build --no-cache --progress=plain --network host -t iacs-ui.24.cogn:v1 . 2>&1 | tee docker-build.log
    5. run the image by mapping port 8080 to its 8000 port (alternatively use the -P option), pass an environment variables file into the container and also supply a short reasonable name for the container (e.g. iacs in the incantation below):
      $ docker run -d -p 8090:8000 --env-file=.env --name iacs iacs-ui.24.cogn:v1
    6. verify the ports the web application being hosted inside the container is listening on:
      $ docker port iacs
      8000/tcp -> 0.0.0.0:8080
      8000/tcp -> [::]:8080
    7. connect your browser to localhost:8080
    8. to "ssh" (sort of) into the container you cannot use docker attach but you must instead use docker exec as follows (see this SO answer for more):
      docker exec -it iacs sh
    9. once you are done, stop the container using docker stop iacs — there's no need to do docker container prune to remove the stopped container as the image was run with the -d option in step 4
  5. permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
  6. provenance
    The user that is running the docker commands (if he is a non-root user) must be added in the docker group. This is done with the following incantation:

    sudo usermode -aG docker $USER
    … but only takes effect after a system reboot. In the meantime you can use newgrp docker in the shell you're working (this will result in a new shell with the current user being part of the docker group).

  7. [Errno 101] Network is unreachable
  8. In November 2024 when going through this docker beginners tutorial (also saved here) I encountered this trace:

    In the end I had to change the docker build invocation from:

    docker build . -t mperdikeas/catnip
    to:
    docker build . --network host -t mperdikeas/catnip

    In initially commented on an already existing bug report and then reported my solution here.

    The solution was found in this thread which also reports at least one additional approach.

    See also this ChatGPT thread of mine.