Docker Quickstart

Simple Definition: Docker is an application which helps in Management of Containers in a very smooth and great way


Installation of Docker:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce
sudo usermod -aG docker cloud_user ————-> To Run docker as non-root user( Add user to docker group)
systemctl enable docker
systemctl start docker


Docker Images:

docker -h ————–> Get all the docker commands.
docker version
docker pull ubuntu:16.04
docker images ————–> To check how many images docker have
docker images –no-trunc
docker image ls -a
docker image history nginx ————-> All information of the Image
docker image history –quiet nginx ————-> Only Displays the ID of the Image
docker image history
docker run hello-world
docker run hello-world:latest
docker image prune ————— Removes all Images
docker image rm
docker login ————–> To login to Docker HUB (https://hub.docker.com)
docker push ubuntu:16.04 ————–> Push the Image ( docker image push /: )
docker tag “IMAGEID” “REPOSITORY”:tag
docker tag hello-world:latest hello-world:latezt
docker tag fce289e99eb9 hello-world:tag2
docker rmi “IMAGEID” ————————-> To remove the images

EXPOSE Port: Accesssiblity to container itself on Localhost.
Publish Port: Accesssiblity to Container from Outside World.

DOCKER FILE CONCEPT:

vi dockerfile # Create a new dockerfile in some directory ( Lets assume : mkdir DOCKER-project)

FROM ubuntu:16.04 # Pull Ubuntu Image from DockerHUB
LABEL maintainer=”Support@automateinfra” # You can give Author details here
RUN apt-get update # Run the Update command
RUN apt-get install -y python3 # Run the Python install command

  • docker build . or docker build dockerfile # Build the Docker Image using dockerfile
  • docker tag 829b396ed1eb myrepo:mytag # TAG the Docker Image u