first row

This commit is contained in:
nutzer26
2022-12-13 09:19:15 +01:00
commit 4f6426ff6f
8 changed files with 805 additions and 0 deletions

70
first_con Normal file
View File

@@ -0,0 +1,70 @@
# subcommand help
docker container run --help
# start a distribution
docker container run ubuntu hostname
# some base images are reduced!
docker container run debian ip a s
# Failure: Ip tool isn't installed
# use small base distros like alpine
docker container run alpine ip a s
# all running on same kernel
docker container run alpine uname -a
# hups: container doesn't removed!
docker container ls -a
# start tools better with --rm
docker container run --rm ubuntu cat /etc/os-release
docker container run --rm debian cat /etc/os-release
docker container run --rm alpine cat /etc/os-release
# -d daemon
# --rm delete after process terminated
# --tty -t create tty
# -i interactive
docker container run -d --rm -ti alpine sleep 3600
# list only ids
docker container ls -qa
# https://docs.docker.com/engine/reference/commandline/ps/#formatting
docker container ls -a --format "{{.ID}}" | xargs docker container rm
# remove al unused containers
docker container prune
# start a shell interactive inside a container distro
docker container run -it debian /bin/sh
apt update
apt install iproute2 procps
ip a s
ps -ef
exit
# use distribution native package systems
docker container run -ti alpine /bin/sh
ps -ef
ip a s
apk add curl
exit
# list all
# -a for all container
docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3663b9e4bfcd alpine "/bin/sh" 6 minutes ago Up 5 seconds nice_heisenberg
# restart a container
# -lq list last created container and only the id
docker container start $(docker container ls -lq)
docker container restart $(docker container ls -lq)
# attach to terminal
docker container attach $(docker container ls -lq)
curl google.de
# detach terminal
CTRL-p CTRL-q
# list all process of the last container namespace
docker container top $(docker container ls -lq)
# >Prozesse aus Sicht des Host im letzten Container
docker container exec $(docker container ls -lq) ps -ef
# >Prozesse Sichtbarkeit im letzten Container
pstree
# show threads
pstree -p
ps axjf