Docker
Docker
Q. What is Docker?
Docker is a open source tools to make it easier to create, deploy, and run applications by us-
ing containers.
A container is a runtime instance of an image, It runs completely isolated from the host envi-
ronment by default, only accessing host files and ports if configured to do so.
Q. What is Docker-Compose?
Compose is a tool for defining and running multi-container Docker applications. With Com-
pose, you use a Compose file to configure your application’s services. Then, using a single
command, you create and start all the services from your configuration.
Docker compose uses UP command to start all container defined inside yml file.
Docker command line uses RUN to start container from docker image.
Docker command line uses START to start container from stoped state.
Q. Installation
--storage-driver devicemapper this line needed because as you can see below screenshot
on centos it only supports devicemapper and by default it start with overlay2
Q. Docker Basics
## To stop container
docker stop container_id
## to delete image
docker rmi -f imageid_or_tag:repository
## To check any information about container ## because result is json you can use
format
docker inspect container
docker inspect –format ’{{ .NetworkSettings.IPAddress }}’ container_id
## To stop container
docker stop container_id
## to delete image
docker rmi -f imageid_or_tag:repository
## To check any information about container ## because result is json you can
use format
docker inspect container
docker inspect --format '{{ .NetworkSettings.IPAddress }}' container_id
Dockerfile
Here every command(Like FROM, COPY, ADD......) will create a layer how many layer will be
image will be heavy.
FROM centos:latest
Dockerfile is help us to run command on base image and give us newly created image
So here centos:latest is our base image
RUN \
/usr/bin/bash /root/script.sh && \
rm -f /etc/localtime && \
ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
COPY is simply copy file from host to inside image’s running container
ADD will copy file untar it and remove tar file and you can also use it for download any thing
from link also
WORKDIR /jobs/foreMfore_deploy
WORKDIR say when you start container by default it will cd to this path for you
EXPOSE 8080 8040 8020 8090
CMD ["/usr/bin/supervisord", "-n"]
Deployment Process
Folder structure
● entrypoint
● projectname (gocash)
● prodpp
● yml
bake-pp.sh is used by praneeth for bake source code in docker and upload artifacts to s3
TAG = jcb-1.1
ENV = pp
GOAL = deploy
PROJECT = mfore/bin/bash /docker/entrypoint/bake-pp.sh jcb-1.1 pp bake mfore
TAG = jcb-1.1
ENV = pp
GOAL = deploy
PROJECT = mfore
Internally based on project name i pick correct yml file and change tag inside yml file and
start compose file
deploy-prodp.sh is uded by praneeth for to deploy from s3 and start test cases but this shell
script take care of change tag inside yml file and start container
And one more import point is in both bake and deploy i use ansible because image should
created with jcb_tag so that if at any time its fail we can go inside docker based on jcb_tag
and debug it.
For every project i use only two yml file one for bake and another is deploy
BAKE : pull source code from github and compile and tar and upload into s3
DEPLOY : pull from s3 untar link to current and start services
Under /docker/prodpp/logs you will get logs of container service logs and its flush every
time during deployment process.