| command / prompt | description |
|---|---|
| docker build --network host --progress=plain -t <tag name> . | build using the Dockerfile in the current dir. The --progress=plain part of the incantation supprisingly produces way more verbose output. |
| command / prompt | description |
|---|---|
| docker run -it --entrypoint=sh <image> | start up a container but supply a different entrypoint. This has the effect of not executing the CMD supplied in the Dockerfile and is very useful for debugging. In other words, it can be used to override CMD when running a Docker image. |
| docker run -d -p 8081:80 --name <container-name> --env-file .env -e X=Y <image-name> | start up container in detached mode, map its local port 80 to the host's port 8081, give it the name foo-cont and pass tt environment variables from the .env file overriding env variable X with the value Y |
| 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 |
| /var/lib/docker | where are docker containers stored |
To test locally, on port 8081, with your own supplied username / password do:
$ docker build --network host -t lpis_geospatial_server . $ docker run -d -p 8081:8080 --name lpis_geo -e GEOSERVER_ADMIN_USER=changeme -e GEOSERVER_ADMIN_PASSWORD=changeme lpis_geospatial_serverThe above runs the container in detached mode (-d) and exposes the GeoServer at t doche localhost:8081/geoserver/web URL. It is also possible to open an interactive shell to the GeoServer container constructed above by doing, as usual:
docker exec -it lpis_geo shOnce inside (i.e. in a shell in the running container) you can do:
curl -L -b cookies.txt -c cookies.txt localhost:8080/geoserver/web -o geoserver.htmlto fetch the geoserver home page or use ss -tulnp to confirm the port being listened to.
$ docker build --network host -t iacs-ui.24.cogn:v1 .
docker build --no-cache --progress=plain --network host -t iacs-ui.24.cogn:v1 . 2>&1 | tee docker-build.log
$ docker run -d -p 8090:8000 --env-file=.env --name iacs iacs-ui.24.cogn:v1
$ docker port iacs 8000/tcp -> 0.0.0.0:8080 8000/tcp -> [::]:8080
docker exec -it iacs sh
provenance
The user that is running the docker commands (if he is a non-root user) must be added in the
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).
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/catnipto:
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.