neulatuntimittari.2.01 docker
26.09.21
CLI v Desktop
I think I’ll be using the Docker CLI interface. The docker documentation nudges me toward the Desktop products, but I’m not sure I need that. I have used the CLI interface in the past, and that seems to be the most intuitive for development, for me.
Heres a comparison from geeks for geeks # Docker CLI vs Docker Desktop
Why do something in a difficult way when it can be done easier? Is a question I struggle with when deciding these things. If the desktop application is more powerful, why struggle with CLI? Because I am protestant?
Installed Docker engine using APT: https://docs.docker.com/engine/install/ubuntu/
- no problems
CLI getting started
####### Important commands: After installation, verify that Docker is running:
sudo systemctl status docker
If Docker is not running, start it manually:
sudo systemctl start docker
Detaching from a container once it is running:
Once attached to a container, users detach from it and leave it running using the using
CTRL-p CTRL-qkey sequence. This detach key sequence is customizable using thedetachKeysproperty. […]
Viewing containers:
karri@karri-ThinkPad-P1-Gen-3:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
07c17d6c157b ubuntu "bash" 5 minutes ago Up 5 minutes thirsty_shaw
d7c356190a1f hello-world "/hello" 5 minutes ago Exited (0) 5 minutes ago wonderful_herschel
Stopping a container after it has started running and user has detached from it:
karri@karri-ThinkPad-P1-Gen-3:~$ sudo docker container stop thirsty_shaw
thirsty_shaw
karri@karri-ThinkPad-P1-Gen-3:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
07c17d6c157b ubuntu "bash" 7 minutes ago Exited (137) 4 seconds ago thirsty_shaw
d7c356190a1f hello-world "/hello" 7 minutes ago Exited (0) 7 minutes ago wonderful_herschel
26.09.30
A container is a running image
Running multiple parts of a application as containers can be done efficiently with docker compose, using a compose.yaml file.
- This way the different parts of the application can be held separate as their own modules, and calls to the application api can be managed by a proxy
After starting an application instance that has multiple containers, you can stop and remove them by:
karri@karri-ThinkPad-P1-Gen-3:~/getting-started-todo-app$ sudo docker rm --force todo
karri@karri-ThinkPad-P1-Gen-3:~/getting-started-todo-app$ l
backend/ client/ compose.yaml Dockerfile LICENSE README.md
karri@karri-ThinkPad-P1-Gen-3:~/getting-started-todo-app$ sudo docker compose down --volumes
[+] down 6/6
✔ Container getting-started-todo-app-client-1 Removed 0.6s
✔ Container getting-started-todo-app-proxy-1 Removed 4.8s
✔ Container getting-started-todo-app-mysql-1 Removed 0.6s
✔ Container getting-started-todo-app-phpmyadmin-1 Removed 1.2s
✔ Volume getting-started-todo-app_todo-mysql-data Removed 0.0s
✔ Network getting-started-todo-app_default Removed
the compose down command will remove the containers, but keep the images and volumes. the –volumes flag deletes objects in persistent storage, like contents of DBs