Dockerday 1
Dockerday 1
============================
===================================================================================
=====================
note: if number of application are more will go with microservices concept (docker
and kubernetes)
DOCKER IMAGE:
Docker images are read-only templates that contain instructions for creating a
container. A Docker image is a snapshot or blueprint of the libraries and
dependencies required inside a container for an application to run
CONTAINERS:
A Docker container image is a lightweight, standalone, executable package of
software that includes everything needed to run an application: code, runtime
its same as a server/vm.
operating system independent
(Ec2 server=AMI, CONTAINER=IMAGE)
os will be managed in image
Note : By default Docker works with the root user and other users can only access
to Docker with sudo commands. However, we can bypass the sudo commands by creating
a new group with the name docker and add ec2_user.
newgrp docker
sudo chmod 666 /var/run/docker.sock # to give access docker demon to run docker
server
#If you want to see an extended version of the version details, such as the API
version, Go version, and Engine Version, use the version command without dashes.
give below command
docker version
# ----commands:---- #
docker run -it imagename /bin/bash --will enter into the container interact
terminal
docker run -dt imagename -we are not enter into the container detach terminal
## To login container ##
docker exec -it <continername or continerid> /bin/bash # to login running container
1.if you want to come out from container without stop give "ctrl p+q" or exit
(container already running while login time so no impact)
## To login container ##
docker run -it <imagename> /bin/bash # to create container from image and also
interactive (login mode)
1.if you want to come out from container without stop give "ctrl p+q"
docker run -dt <imagename> (detach mode not going to be interacted with container)
ps -ef --to know how many processors running if it is in vm many process we can
see but it is in container onle few becuase its light weight
## danger commands##
docker rmi <imagename> ##to delete image if image is not tagging to any container
weather it is running or stopped
docker rmi <imageID> -f #forcrfully delete image even respective container weather
it is running or stopped
docker system prune -a to remove all images (if images are tag to stopped
containers)
## container ------
docker rm <containername or containerid> ### to remover stopped container
# --Enabeling port-- #
docker run -dt -p 3000:3000 --name project-2 ubuntu #along port expose
===================================================================================
docker run -dt -p <local host port>:<container run port> --name <name of the
container> <name of the image>
============================================================