Docker, the new trending containerization technique, is winning hearts with its lightweight, portable, “build once, configure once and run anywhere” functionalities.
An instance of an image is called container. You have an image, which is a set of layers. If you start this image, you have a running container of this image. You can have many running containers of the same image.
So a running image is a container.
-
Lists only running containers:
sudo docker ps
-
Lists all containers:
sudo docker ps -a
-
Remove Stopped Containers:
docker ps -a | awk '/Exit/ {print $1}' | xargs docker rm
-
Remove all containers (including running containers):
docker ps -q -a | xargs docker rm
-
List available:
images sudo docker images
-
Restart the Docker daemon. If you are in Ubuntu 14.04, use docker.io instead of docker
sudo service docker restart
-
To remove a container:
docker rm <Container ID>
-
To remove all containers:
docker rm $(docker ps -a -q)
-
To remove images:
docker rmi <Container ID>
-
To remove all images:
docker rmi $(docker ps -a -q)
- Error: "dial unix /var/run/docker.sock: permission denied" on Linux 14.04
- Solution: Adding myself to the docker group by
sudo usermod -a -G docker <username>
and rebooting (logout/login might have worked as well) did the job for me. I do not see the permission denied anymore when I issue docker commands.
Do I need OpenStack if I use Docker?
Chef: Chef is an automation platform that transforms infrastructure into code.
This is a configuration management software. Most of them use the same paradigm: they allow you to define the state you want a machine to be, with regards to configuration files, software installed, users, groups and many other resource types. Most of them also provide functionality to push changes onto specific machines, a process usually called orchestration.
Vagrant: Create and configure lightweight, reproducible, and portable development environments.
It provides a reproducible way to generate fully virtualized machines using either Oracle's VirtualBox or VMWare technology as providers. Vagrant can coordinate with a configuration management software to continue the process of installation where the operating system's installer finishes. This is known as provisioning.
Docker: An open source project to pack, ship and run any application as a lightweight container
The functionality of this software somewhat overlaps with that of Vagrant, in which it provides the means to define operating systems installations, but greatly differs in the technology used for this purpose. Docker uses Linux containers, which are not virtual machines per se, but isolated processes running in isolated filesystems. Docker can also use a configuration management system to provision the containers.
OpenStack: Open source software for building private and public clouds.
While it is true that OpenStack can be deployed on a single machine, such deployment is purely for proof-of-concept, probably not very functional due to resource constraints.
The primary target for OpenStack installations are bare metal multi-node environments, where the different components can be used in dedicated hardware to achieve better results.
A key functionality of OpenStack is its support for many virtualization technologies, from fully virtualized (VirtualBox, VMWare), to paravirtualized (KVM/Qemu) and also containers (LXC) and even User Mode Linux (UML).
CoreOS is a minimal Linux-based operating system aimed at large-scale server deployments. CoreOS is written with scalability and security in mind. Next to that it is stongly biased towards Docker: every process running on a CoreOS server should be running in a Docker container. CoreOS comes with Docker and etcd pre-installed.
Docker is a platform to create light-weight, stand-alone, containers from any application. It allows you to run processes in a pseudo-VM that boots extremely fast (under 1 second) and isolates all its resources.
confd is a configuration management tool built on top of etcd. confd can watch certain keys in etcd, and update the related configuration files as soon as the key changes. After that, confd can reload or restart applications related to the updated configuration files. This allows you to automate configuration changes to all the servers in your cluster, and makes sure all services are always looking at the latest configuration.
etcd is a highly available, distributed key/value store that is built to distribute configuration updates to all the servers in your cluster. Next to that it can be used for service discovery, or basically for any other distributed key/value based process that applies to your situation.
fleet is a layer on top of systemd, the well-known init system. Fleet basically lets you manage your services on any server in your cluster transparently, and gives you some convenient tools to inspect the state of your services.
stop and remove containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)