What are containers
Isolated environments which helps in running multiple applications in a single machine.
Difference between containers and VMs
VMs have their own OS KERNEL, however, container shares the Host OS Kernel
Different between Docker and Docker Inc?
Docker: Container technology and Container Engine.
Docker Inc: Name of the organisation which open sourced container technology in public domain.
Docker Engine Vs Docker Hub
Docker Engine: Container Engine required to run the containers.
Docker Hub: Image repository for saving Docker images created by the community.
Is it possible to run container engine of Windows on Linux?
No
How to install Docker
Instructions executed behind the scene, when we run
“docker run debian echo “hello world”?
When do container stops?
It stops when main process stops.
How to run “interactive” session with container’s bash?
Using “-i” flag:
docker run -i debian /bin/bash
How to attach a “telewriter terminal - tty”, to a container?
Using “-t” flag
docker run -it debian /bin/bash
How to change the hostname of the container?
Using “-h” flag
docker run -it -h debian /bin/bash
Does debian image contains all commands by default?
No, it contains only subset of commands.
It’s default location is /bin
What will happen, if we delete the “/bin” directory?
The container will be useless, as there will be no commands to get execute.
How to list all the containers running in a machine with active state?
docker ps
How to list all the containers running in a machine with active and inactive state?
docker ps -a
How to list all containers with some conditions?
docker ps -f
How to print only IDs of the container during listing?
docker ps -q
What is default name and ID of any container?
Default ID: AlphaNumeric code, which cannot be changed.
Name: Combination of two words separated by underscore.
First word: Adjective
Second word: Name of a famous scientist, Hacker or programmer
How to change the name of the container?
docker run –name
How to get detailed information about a container?
docker inspect
Is it possible to extract required information from “docker inspect output” ?
The output of “docker inspect” command is a JSON.
By using go-lang template, we can extract information from “docker inspect”:
docker inspect –format {{.Network.ip}}
How to get logs from a container?
docker logs
What are different stages of container lifecycle?
running > exited > removed
How to remove a container without volume?
docker rm