Getting started with Docker part 1

Docker is a container technology built in runC, a container runtime that implements their specification and serves as a basis for other higher-level tools.

Docker consists of Docket engine a open source containerization technology & Docker Hub a SaaS from to store or share your docker images.

Docker engine : Is basically a client-server application with
server called “dockerd” responsible for running docker process (Each container is nothing but a process these are isolated using linux namespaces)

API access :REST API access that can be used by other programs to talk with dockerd daemon.

Interface : A cli interface command line utility docker.

container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it.

Containers share same kernel as the host operating system,due to this reason containers can be setup and started with in few seconds of time as compared virtual machines.

Docker container runtime includes containerd integrated with runC to provide better functionality, containerd is used in docker, kubernetes and other container platforms.

A more detailed information can be read at https://blog.docker.com/2017/12/containerd-ga-features-2/

docker can be installed on linux distors from package managers like dnf,rpm,apt,aur or following instructions from docker site https://docs.docker.com/install/linux/docker-ce/fedora/

there is another method to install docker getting the script from https://get.docker.com/ and installing.

#curl -fsSL get.docker.com -o get-docker.sh
#bash get-docker.sh

I am following the steps provided at https://docs.docker.com/install/linux/docker-ce/fedora/

$sudo dnf -y install dnf-plugins-core

$ sudo dnf config-manager \
    --add-repo \
    https://download.docker.com/linux/fedora/docker-ce.repo

$sudo dnf install docker-ce 

$sudo systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.ser

$sudo systemctl start docer

$sudo usermod -aG docker $USER 

$newgrp docker 

$docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

#docker daemon is available to access for root user only, to allow user to access docker daemon,add user to docker group
$sudo usermod docker $USER

To reflect changes without restarting the session use
$newgrp docker ( “newgrp docker” has to be executed as normal user)

$docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE

#when you want to run a container docker will look for the image on the local system if the image is available it will create a container using the image and run.
or docker will pull the image from the docker public registry then starts a container.

I am trying to start a centos7 docker container in a daemon mode, when i execute the command for the very first time there is no centos7 docker image on my local system, docker is going to pull the image from docker registry.

$docker run -itd centos7 /bin/bash 
Unable to find image 'centos:latest' locally

We need a docker account to access the repository of images also to push our images to our docker hub account.

$docker run -itd centos7 /bin/bash 
Unable to find image 'centos:latest' locally
docker: Error response from daemon: pull access denied for centos7, repository does not exist or may require 'docker login'.
See 'docker run --help'.

#lets authenticate docker hub account

$docker login 
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: pawaanv
Password: 
Login Succeeded

if we try to run the command again, docker pull centos will work even if we don’t authenticate docker, since i will be uploading my images to docker hub, authentication to docker was enabled.

$docker run --name centos7 -d centos
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
5e35d10a3eba: Pull complete 
Digest: sha256:dcbc4e5e7052ea2306eed59563da1fec09196f2ecacbe042acbdcd2b44b05270
Status: Downloaded newer image for centos:latest
ffa58a4c6066f79c1e1136788868802a5dd43d4a827138ab7ddf3f6ab3bd9c6f

$docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              2d194b392dd1        2 weeks ago         195MB


Docker service can be checked from systemctl command.

#sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2018-03-25 17:21:47 IST; 5min ago
     Docs: https://docs.docker.com
 Main PID: 1164 (dockerd)
    Tasks: 21
   Memory: 119.3M
      CPU: 2.227s
   CGroup: /system.slice/docker.service
           ├─1164 /usr/bin/dockerd
           └─1575 docker-containerd --config /var/run/docker/containerd/containerd.toml

Mar 25 17:21:44 server.sand.box dockerd[1164]: time="2018-03-25T17:21:44.991131300+05:30" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Mar 25 17:21:44 server.sand.box dockerd[1164]: time="2018-03-25T17:21:44.991872597+05:30" level=warning msg="Your kernel does not support cgroup rt period"
Mar 25 17:21:44 server.sand.box dockerd[1164]: time="2018-03-25T17:21:44.991916516+05:30" level=warning msg="Your kernel does not support cgroup rt runtime"
Mar 25 17:21:44 server.sand.box dockerd[1164]: time="2018-03-25T17:21:44.993502887+05:30" level=info msg="Loading containers: start."
Mar 25 17:21:46 server.sand.box dockerd[1164]: time="2018-03-25T17:21:46.505308036+05:30" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a pr
Mar 25 17:21:46 server.sand.box dockerd[1164]: time="2018-03-25T17:21:46.902762993+05:30" level=info msg="Loading containers: done."
Mar 25 17:21:47 server.sand.box dockerd[1164]: time="2018-03-25T17:21:47.172794664+05:30" level=info msg="Docker daemon" commit=0520e24 graphdriver(s)=overlay2 version=18.03.0-ce
Mar 25 17:21:47 server.sand.box dockerd[1164]: time="2018-03-25T17:21:47.196538773+05:30" level=info msg="Daemon has completed initialization"
Mar 25 17:21:47 server.sand.box dockerd[1164]: time="2018-03-25T17:21:47.218926571+05:30" level=info msg="API listen on /var/run/docker.sock"
Mar 25 17:21:47 server.sand.box systemd[1]: Started Docker Application Container Engine