DEV Community

Cover image for Docker Basics
Adya Shukla
Adya Shukla

Posted on • Edited on

Docker Basics

As a newbie the first question that comes to mind is What is Docker ?
So, A docker is a command line program, a background daemon and set of remote services that simplifies installation, running, publishing or removing software.

Docker is NOT virtualization.

Running docker means running two programs : docker CLI and docker daemon.
Docker containers are isolated with 8 aspects:
1 . PID namespace : process identifiers and capabilities
2 . UTS namespace : host and domain space
3 . MNT namespace : File system access and structure
4 . IPC namespace : Process communication over shared memory
5 . NET namespace : Network access and structure
6 . USR namespace : User name and identifiers
7 . chroot() : controls location of file system root
8 . cgroups : Resource protection

What are Images ?
A bundled snapshot of all the files that should be available to a program running inside a container.

What is container ?
It is a running or stopped instance of some image.

We can create as many container from an image but containers that are created from same image don't share changes to their file systems.
Here are few basic commands to run :

1 . docker run hello-world
You will get output as :
Hello from Docker!
This message shows that your installation appears to be working correctly.

2 . docker run --detach --name web nginx : latest
or
docker run -d --name web nginx : latest
where -d or --detach will start the program in background

3 . To check currently running containers :
docker ps
This will only display running containers but if you want to see all including those in exited state then :
docker ps -a

4 . To check docker logs :
docker logs

5 . To continue watching logs :
docker logs --follow

These are few very basics of the docker. Hope it helps !!!

Top comments (0)