Containers are ‘Applications’ – they consists of images.
Include so called Volumes to keep persistent data and exchange environment variables between containers.
Dangled images are images included in still existing older versions of your container.
Unused images are totally orphaned images.
Avoid –link parameter – it’s deprecated.
Use Volumes instead.
-
Connecting volumes: -v
Environment variables: -e
Ports: -p
Managing Volumes:
Creating:
docker volume create --opt o=size=1024m --opt type=ext4 --opt device=DEVONHOST MyVolume
Attention!
The local driver does not support volume size limitation!
Other stuff:
docker volume create Create a volume
docker volume inspect Display detailed information on one or more volumes
docker volume ls List volumes
docker volume prune Remove all unused local volumes
docker volume rm Remove one or more volumes
Creating and running containers:
# docker run -d --name VolCon -p HOSTPORT:CONTAINERPORT -e MYENV=LALALA -v HOSTPATH:CONTAINERPATH:ro xxaxxelxx/lsssd_volumecontrol
Example:
# docker run -d --name VolCon -p 65522:22 -e MYENV=LALALA -v MyVolume:/incuded_volume -v /sys:/host/sys:ro xxaxxelxx/lsssd_volumecontrol
Stopping/start/restart containers:
docker stop/start/restart CONTAINERNAME/CONTAINERID
Managing containers:
List running containers and show all infos:
docker ps
List running containers and show id only:
docker ps -q
List stopped containers and show all infos:
docker ps -a
List stopped containers and show is only:
docker ps -aq
List images used by existing containers showing all parameters:
docker images
List images used by existing containers showing id only:
docker images
List ALL images used and unused by existing containers showing all parameters:
docker images -a
List ALL images used and unused by existing containers showing id only:
docker images -aq
Delete containers:
docker rm CONTAINERNAME/CONTAINERID
Delete images:
docker rmi ID
Using xarg example:
docker images -aq | xarg docker rmi
Delete unused images:
docker image prune -af
Delete stopped containers and dangling images:
docker system prune
Modify existing containers:
docker update --restart=always CONTAINERNAME
Arguments limiting a containers resources:
--blkio-weight uint16
--cpu-period int
--cpu-quota int
--cpu-rt-period int
--cpu-rt-runtime int
-c, --cpu-shares int
--cpus decimal
--cpuset-cpus string
--cpuset-mems string
--kernel-memory bytes
-m, --memory bytes
--memory-reservation bytes
--memory-swap bytesenable unlimited swap
--pids-limit int
--restart string