SlideShare une entreprise Scribd logo
1  sur  15
Docker development Best Practices
1.CI/CD for Testing and Deployment: Experts recommend using Docker Hub or any other CI/CD
pipeline to build and tag a Docker image whenever a pull request is created. Furthermore, the images
should be signed by the development, security, and testing teams before they are pushed to production
so that it is constantly tested for quality by the desired teams.
2.Use Different Environments for Development and Testing: One of the best practices while using
Docker for development is creating different testing and development environments. Doing so will allow
the developer to keep the Docker files isolated and execute them without influencing the final build after
testing.
3.Update Docker to the Latest Version: Before you begin working on a Docker project, you need to
ensure that you update the Docker to the latest version. Even though it will not directly impact the
project, it will provide you with the latest features that Docker has to offer. New updates also have
certain security features, safeguarding the project from potential attacks
Docker container Best Practices
1.Frequently Backup a Single Manager Node: A common Docker container practice is to back a
single managed node frequently, which helps admins in restoration. Docker Swarm and Universal
Control Plane data are part of every node, so backing up a single manager node can get the job done
for the admins.
2.Cloud Deployment of a Docker Container: When deploying a Docker container to a cloud, both
Amazon Web Services and Microsoft Azure do not have integrated hosts optimized for Docker. They
use the Kubernetes cluster for deployment. A standard virtual machine should be created by the admins
who prefer to deploy a single container. Apart from that, securing the secure socket shell and installing
Docker is the next step. Admins can now deploy the application on a cloud after installing Docker.
3.Control Docker Containers through a Load Balancer: A load balancer helps admins get good
control over Docker containers which helps them in making containers highly available and scalable.
The most commonly used load balancer is NGINX which can easily be installed on Docker. This load
balancer supports multiple balancing methods, static and dynamic caching, rate limiting, and multiple
distinct applications.
1. Beware of inheritance and dependencies
Your containers inherit a parent image that generally includes its base
operating system and dependencies—things like dependent packages,
default users, etc. Those inherited attributes and dependencies might
expose your containers to unnecessary risk. Make sure you’re aware of
the inherited attributes and take any additional steps necessary to further
isolate and protect your containers.
2. Limit container interaction
Container security has emerged as a serious concern for many
organizations—specifically how containers interact with one another and
with the outside world. Your containers should not accept connections on
exposed ports through any network interface. You should take steps both
to control how—and how much—containers interact with each other
internally, and limit the number of containers that have contact with the
outside world so you can minimize exposure to external risks.
3. Monitor containers for vulnerabilities
One of the challenges of using a code repository like Docker Hub is that
once a container image is uploaded to the repository nobody takes
responsibility for keeping it patched and secure. It might be fine when
originally created, but over time new vulnerabilities and exploits are
discovered and you need to scan for those before using containers in
production. A tool like Twistlock can help you monitor for and identify
vulnerabilities in your container images.
4. Run containers as read only where possible
One of the best and simplest ways to limit exposure to risk for container is
to run them in read-only mode. That obviously won’t work for all
containers—there will be containers that must accept input of some sort in
order for apps to work, but containers that can be run in read-only mode
should be. You should also never run containers in privileged mode.
Docker Logging best practices
1.Logging from Application: Logging directly from the application is a method where applications within
the container manage the logging through a framework. The developers will have the utmost control over
the logging event when using this method.
2.Logging Drivers: Logging drivers is a unique feature of Docker that helps read data by the stderr or
stdout streams of the container as they are specifically configured to accomplish this task. Once done, the
host machine stores log files that include the prior data.
3. Dedicated Container for Logging: Having a dedicated container for logging helps in eradicating
dependencies on host machines. This container will be responsible for log file management within the
Docker environment.
4.Sidecar Method: The Sidecar method is undoubtedly among the best if you want to manage
microservices architecture. Here, the sidecars run simultaneously with the parent application, where they
share the same network and volume. These shared resources allow you to expand the app functionalities
and eradicate the need to install any extra configurations.
Dockerfile
When using containers to deploy your applications, one of the most important things
that you must get right is your Dockerfiles. Dockerfiles are how you tell Docker how to
build and deploy your containers. If they aren’t well-written or optimized for your
needs, that can significantly impact how quickly and efficiently you can get new
versions of your application up and running.
Dockerfile Best Practices
- Do not use your Dockerfile as a build script:
A Dockerfile is a set of instructions that can be used to create a custom image.
It should never be used as a build script because it will make your builds
unnecessarily long. When you must compile or bundle software in your
Dockerfile, you should use the ADD instruction. This will copy the files
necessary for compilation into the image before it starts running commands.
This will let you keep the Dockerfile short and manage any dependencies
required for compilation separately from the Dockerfile.
- Use ENV to define environment variables:
Setting environment variables is a best practice for Dockerfiles. Although it
might seem like a small detail, defining your environment variables will make
your containers more portable. This is because your environment variables are
the only thing that can change from one execution to the next. If you have a
variable that must be different both inside and outside of your container, then
you must define it using ENV.
Dockerfile Best Practices
- Commit your Dockerfile to the repository:
One of the best practices of Dockerfiles is committing them to your repository.
This lets you easily and quickly reference it later without remembering all of the
commands that you used or what their order was.
- Be mindful of your base image and its size:
One of the most important things to consider when creating your Dockerfile is
the base image that you’re using. It will increase your Docker image's size if you
have a lot of extraneous code. This will make it much slower for your container
to start up or, even worse, prevent it from starting at all. The best way to avoid
this is by being mindful of which packages and scripts you use. If it doesn’t
seem necessary to include it in the base image, try and find a way to install it
when the container starts up instead. This will save space on your container,
thus making it run more quickly and efficiently.
Dockerfile Best Practices
- Do not expose secrets:
Never share or copy the application credentials or any sensitive information in
the Dockerfile. Instead, use the .dockerignore file to prevent copying files that
might contain sensitive information. The .dockerignore file acts as equivalent to
the .gitignore file, and it lets you specify the files that you want the build process
to ignore.
- Be mindful of which ports are exposed:
When designing your Dockerfile, make sure that you know which ports are
exposed. By default, Docker will expose all of the containers to a range of
random internal ports. This is problematic, as it can expose critical services to
the outside world and leave them open for attack. If you’re using a service that
must be exposed to the public internet, then you must create an entry in the
Dockerfile. This is done by adding 'EXPOSE' in your Dockerfile.
Docker image building Best Practices
Version Docker Images:A common practice among Docker users is using the
latest tag for images which is also the default tag for images. Using this tag will
eradicate the possibility of identifying the running version code based on the image
tag. Not only does it become easier to overwrite it, but it also leads to extreme
complications while doing rollbacks. Make sure to avoid using the latest tag,
especially for base images, as it could unintentionally lead to the deployment of a
new version. Rather than using the default tag, the best practice is to use
descriptors like semantic version, timestamps, or Docker image IDs as a tag. With
the practice of having a relevant tagging scheme, it becomes easier to tie the tag to
the code.
Docker image building Best Practices
Avoid Storing Secrets in Images: Undeniably, confidential data or secrets like SSH keys,
passwords, and TLS certificates are highly sensitive for an organization. Storing such data in
images without encryption can make it easier for anyone to extract and exploit it. This situation is
extremely common when images are pushed into a public registry. Rather than that, injecting
these through build-time arguments, environment variables, and an orchestration tool is the best
practice. In addition, sensitive data can also be added to the .dockerignore file. Another practice
to accomplish this goal is by being specific about the files that should be copied over the image.
Environment Variables:Environment variables are primarily used to keep the application flexible
and secure. These can also be used to pass on sensitive information or secrets. However, these
will still be visible in the logs, child processes, linked containers, and docker inspect. The
following is a frequently used approach for managing secrets.
Docker image building Best Practices
Using a .dockerignore File: The .dockerignore file is used to define the required build context. Before
an image is built, the user has to specify the files and folders that should be excluded from the initial
build context sent to the Docker daemon which is done with the help of the .dockerignore file. Prior to
evaluating the COPY or ADD commands, the entire project’s root is sent to the Docker daemon, making
it a hefty deal. Apart from that, there can be stances when the daemon and the Docker CLI are on
different machines. In that case, the .dockerignore file should be added to local secrets, temporary files,
local development files, or build logs. Doing so can boost the build process, avoid secret leaks, and
reduce the Docker image size.
Image Linting and Scanning: Inspecting the source code for any stylistic or programmatic error that
can cause issues is called lining. Linting can help ensure that the Dockerfiles comply with the right
practice and can be maintained. This process can also be followed in images to determine any
underlying vulnerabilities or issues.
THANK YOU
Like the Video and Subscribe the Channel

Contenu connexe

Similaire à Docker best Practices

Docker_Interview_Questions__Answers.pdf
Docker_Interview_Questions__Answers.pdfDocker_Interview_Questions__Answers.pdf
Docker_Interview_Questions__Answers.pdfRifqiMultazamOfficia
 
Docker interview Questions-2.pdf
Docker interview Questions-2.pdfDocker interview Questions-2.pdf
Docker interview Questions-2.pdfYogeshwaran R
 
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...Puppet
 
Journey to the devops automation with docker kubernetes and openshift
Journey to the devops automation with docker kubernetes and openshiftJourney to the devops automation with docker kubernetes and openshift
Journey to the devops automation with docker kubernetes and openshiftYusuf Hadiwinata Sutandar
 
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...Eric Smalling
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataInfluxData
 
Docker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldDocker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldzekeLabs Technologies
 
Docker Use Cases.pdf
Docker Use Cases.pdfDocker Use Cases.pdf
Docker Use Cases.pdfSimform
 
docker : how to deploy Digital Experience in a container drinking a cup of co...
docker : how to deploy Digital Experience in a container drinking a cup of co...docker : how to deploy Digital Experience in a container drinking a cup of co...
docker : how to deploy Digital Experience in a container drinking a cup of co...Matteo Bisi
 
HPC Cloud Burst Using Docker
HPC Cloud Burst Using DockerHPC Cloud Burst Using Docker
HPC Cloud Burst Using DockerIRJET Journal
 

Similaire à Docker best Practices (20)

Overview of Docker
Overview of DockerOverview of Docker
Overview of Docker
 
Let's dockerize
Let's dockerizeLet's dockerize
Let's dockerize
 
Docker
DockerDocker
Docker
 
Docker Overview
Docker OverviewDocker Overview
Docker Overview
 
Docker_Interview_Questions__Answers.pdf
Docker_Interview_Questions__Answers.pdfDocker_Interview_Questions__Answers.pdf
Docker_Interview_Questions__Answers.pdf
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Docker interview Questions-2.pdf
Docker interview Questions-2.pdfDocker interview Questions-2.pdf
Docker interview Questions-2.pdf
 
Docker
DockerDocker
Docker
 
Webinar : Docker in Production
Webinar : Docker in ProductionWebinar : Docker in Production
Webinar : Docker in Production
 
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
 
Testing Docker Images Security
Testing Docker Images SecurityTesting Docker Images Security
Testing Docker Images Security
 
Journey to the devops automation with docker kubernetes and openshift
Journey to the devops automation with docker kubernetes and openshiftJourney to the devops automation with docker kubernetes and openshift
Journey to the devops automation with docker kubernetes and openshift
 
What is Docker?
What is Docker?What is Docker?
What is Docker?
 
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
 
Docker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldDocker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container world
 
Docker Use Cases.pdf
Docker Use Cases.pdfDocker Use Cases.pdf
Docker Use Cases.pdf
 
docker : how to deploy Digital Experience in a container drinking a cup of co...
docker : how to deploy Digital Experience in a container drinking a cup of co...docker : how to deploy Digital Experience in a container drinking a cup of co...
docker : how to deploy Digital Experience in a container drinking a cup of co...
 
HPC Cloud Burst Using Docker
HPC Cloud Burst Using DockerHPC Cloud Burst Using Docker
HPC Cloud Burst Using Docker
 
The Docker Training in Bangalore From myTectra,Online
The Docker Training in Bangalore From myTectra,OnlineThe Docker Training in Bangalore From myTectra,Online
The Docker Training in Bangalore From myTectra,Online
 

Plus de jeetendra mandal

Eventual consistency vs Strong consistency what is the difference
Eventual consistency vs Strong consistency what is the differenceEventual consistency vs Strong consistency what is the difference
Eventual consistency vs Strong consistency what is the differencejeetendra mandal
 
Batch Processing vs Stream Processing Difference
Batch Processing vs Stream Processing DifferenceBatch Processing vs Stream Processing Difference
Batch Processing vs Stream Processing Differencejeetendra mandal
 
Difference between Database vs Data Warehouse vs Data Lake
Difference between Database vs Data Warehouse vs Data LakeDifference between Database vs Data Warehouse vs Data Lake
Difference between Database vs Data Warehouse vs Data Lakejeetendra mandal
 
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long PollingDifference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long Pollingjeetendra mandal
 
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...jeetendra mandal
 
Difference Program vs Process vs Thread
Difference Program vs Process vs ThreadDifference Program vs Process vs Thread
Difference Program vs Process vs Threadjeetendra mandal
 
Carrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java ProgrammerCarrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java Programmerjeetendra mandal
 
How to become a Software Tester Carrier Path for Software Quality Tester
How to become a Software Tester Carrier Path for Software Quality TesterHow to become a Software Tester Carrier Path for Software Quality Tester
How to become a Software Tester Carrier Path for Software Quality Testerjeetendra mandal
 
How to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software DeveloperHow to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software Developerjeetendra mandal
 
Microservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design PatternMicroservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design Patternjeetendra mandal
 
Event Driven Software Architecture Pattern
Event Driven Software Architecture PatternEvent Driven Software Architecture Pattern
Event Driven Software Architecture Patternjeetendra mandal
 
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...jeetendra mandal
 
Observability vs APM vs Monitoring Comparison
Observability vs APM vs  Monitoring ComparisonObservability vs APM vs  Monitoring Comparison
Observability vs APM vs Monitoring Comparisonjeetendra mandal
 
Disaster Recovery vs Data Backup what is the difference
Disaster Recovery vs Data Backup what is the differenceDisaster Recovery vs Data Backup what is the difference
Disaster Recovery vs Data Backup what is the differencejeetendra mandal
 
What is Spinnaker? Spinnaker tutorial
What is Spinnaker? Spinnaker tutorialWhat is Spinnaker? Spinnaker tutorial
What is Spinnaker? Spinnaker tutorialjeetendra mandal
 
Difference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs BitbucketDifference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs Bitbucketjeetendra mandal
 

Plus de jeetendra mandal (20)

what is OSI model
what is OSI modelwhat is OSI model
what is OSI model
 
What is AWS Cloud Watch
What is AWS Cloud WatchWhat is AWS Cloud Watch
What is AWS Cloud Watch
 
What is AWS Fargate
What is AWS FargateWhat is AWS Fargate
What is AWS Fargate
 
Eventual consistency vs Strong consistency what is the difference
Eventual consistency vs Strong consistency what is the differenceEventual consistency vs Strong consistency what is the difference
Eventual consistency vs Strong consistency what is the difference
 
Batch Processing vs Stream Processing Difference
Batch Processing vs Stream Processing DifferenceBatch Processing vs Stream Processing Difference
Batch Processing vs Stream Processing Difference
 
Difference between Database vs Data Warehouse vs Data Lake
Difference between Database vs Data Warehouse vs Data LakeDifference between Database vs Data Warehouse vs Data Lake
Difference between Database vs Data Warehouse vs Data Lake
 
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long PollingDifference between Client Polling vs Server Push vs Websocket vs Long Polling
Difference between Client Polling vs Server Push vs Websocket vs Long Polling
 
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
 
Difference Program vs Process vs Thread
Difference Program vs Process vs ThreadDifference Program vs Process vs Thread
Difference Program vs Process vs Thread
 
Carrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java ProgrammerCarrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java Programmer
 
How to become a Software Tester Carrier Path for Software Quality Tester
How to become a Software Tester Carrier Path for Software Quality TesterHow to become a Software Tester Carrier Path for Software Quality Tester
How to become a Software Tester Carrier Path for Software Quality Tester
 
How to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software DeveloperHow to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software Developer
 
Events vs Notifications
Events vs NotificationsEvents vs Notifications
Events vs Notifications
 
Microservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design PatternMicroservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design Pattern
 
Event Driven Software Architecture Pattern
Event Driven Software Architecture PatternEvent Driven Software Architecture Pattern
Event Driven Software Architecture Pattern
 
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
 
Observability vs APM vs Monitoring Comparison
Observability vs APM vs  Monitoring ComparisonObservability vs APM vs  Monitoring Comparison
Observability vs APM vs Monitoring Comparison
 
Disaster Recovery vs Data Backup what is the difference
Disaster Recovery vs Data Backup what is the differenceDisaster Recovery vs Data Backup what is the difference
Disaster Recovery vs Data Backup what is the difference
 
What is Spinnaker? Spinnaker tutorial
What is Spinnaker? Spinnaker tutorialWhat is Spinnaker? Spinnaker tutorial
What is Spinnaker? Spinnaker tutorial
 
Difference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs BitbucketDifference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs Bitbucket
 

Dernier

OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 

Dernier (20)

OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 

Docker best Practices

  • 1.
  • 2. Docker development Best Practices 1.CI/CD for Testing and Deployment: Experts recommend using Docker Hub or any other CI/CD pipeline to build and tag a Docker image whenever a pull request is created. Furthermore, the images should be signed by the development, security, and testing teams before they are pushed to production so that it is constantly tested for quality by the desired teams. 2.Use Different Environments for Development and Testing: One of the best practices while using Docker for development is creating different testing and development environments. Doing so will allow the developer to keep the Docker files isolated and execute them without influencing the final build after testing. 3.Update Docker to the Latest Version: Before you begin working on a Docker project, you need to ensure that you update the Docker to the latest version. Even though it will not directly impact the project, it will provide you with the latest features that Docker has to offer. New updates also have certain security features, safeguarding the project from potential attacks
  • 3. Docker container Best Practices 1.Frequently Backup a Single Manager Node: A common Docker container practice is to back a single managed node frequently, which helps admins in restoration. Docker Swarm and Universal Control Plane data are part of every node, so backing up a single manager node can get the job done for the admins. 2.Cloud Deployment of a Docker Container: When deploying a Docker container to a cloud, both Amazon Web Services and Microsoft Azure do not have integrated hosts optimized for Docker. They use the Kubernetes cluster for deployment. A standard virtual machine should be created by the admins who prefer to deploy a single container. Apart from that, securing the secure socket shell and installing Docker is the next step. Admins can now deploy the application on a cloud after installing Docker. 3.Control Docker Containers through a Load Balancer: A load balancer helps admins get good control over Docker containers which helps them in making containers highly available and scalable. The most commonly used load balancer is NGINX which can easily be installed on Docker. This load balancer supports multiple balancing methods, static and dynamic caching, rate limiting, and multiple distinct applications.
  • 4. 1. Beware of inheritance and dependencies Your containers inherit a parent image that generally includes its base operating system and dependencies—things like dependent packages, default users, etc. Those inherited attributes and dependencies might expose your containers to unnecessary risk. Make sure you’re aware of the inherited attributes and take any additional steps necessary to further isolate and protect your containers. 2. Limit container interaction Container security has emerged as a serious concern for many organizations—specifically how containers interact with one another and with the outside world. Your containers should not accept connections on exposed ports through any network interface. You should take steps both to control how—and how much—containers interact with each other internally, and limit the number of containers that have contact with the outside world so you can minimize exposure to external risks.
  • 5. 3. Monitor containers for vulnerabilities One of the challenges of using a code repository like Docker Hub is that once a container image is uploaded to the repository nobody takes responsibility for keeping it patched and secure. It might be fine when originally created, but over time new vulnerabilities and exploits are discovered and you need to scan for those before using containers in production. A tool like Twistlock can help you monitor for and identify vulnerabilities in your container images. 4. Run containers as read only where possible One of the best and simplest ways to limit exposure to risk for container is to run them in read-only mode. That obviously won’t work for all containers—there will be containers that must accept input of some sort in order for apps to work, but containers that can be run in read-only mode should be. You should also never run containers in privileged mode.
  • 6. Docker Logging best practices 1.Logging from Application: Logging directly from the application is a method where applications within the container manage the logging through a framework. The developers will have the utmost control over the logging event when using this method. 2.Logging Drivers: Logging drivers is a unique feature of Docker that helps read data by the stderr or stdout streams of the container as they are specifically configured to accomplish this task. Once done, the host machine stores log files that include the prior data. 3. Dedicated Container for Logging: Having a dedicated container for logging helps in eradicating dependencies on host machines. This container will be responsible for log file management within the Docker environment. 4.Sidecar Method: The Sidecar method is undoubtedly among the best if you want to manage microservices architecture. Here, the sidecars run simultaneously with the parent application, where they share the same network and volume. These shared resources allow you to expand the app functionalities and eradicate the need to install any extra configurations.
  • 7.
  • 8. Dockerfile When using containers to deploy your applications, one of the most important things that you must get right is your Dockerfiles. Dockerfiles are how you tell Docker how to build and deploy your containers. If they aren’t well-written or optimized for your needs, that can significantly impact how quickly and efficiently you can get new versions of your application up and running.
  • 9. Dockerfile Best Practices - Do not use your Dockerfile as a build script: A Dockerfile is a set of instructions that can be used to create a custom image. It should never be used as a build script because it will make your builds unnecessarily long. When you must compile or bundle software in your Dockerfile, you should use the ADD instruction. This will copy the files necessary for compilation into the image before it starts running commands. This will let you keep the Dockerfile short and manage any dependencies required for compilation separately from the Dockerfile. - Use ENV to define environment variables: Setting environment variables is a best practice for Dockerfiles. Although it might seem like a small detail, defining your environment variables will make your containers more portable. This is because your environment variables are the only thing that can change from one execution to the next. If you have a variable that must be different both inside and outside of your container, then you must define it using ENV.
  • 10. Dockerfile Best Practices - Commit your Dockerfile to the repository: One of the best practices of Dockerfiles is committing them to your repository. This lets you easily and quickly reference it later without remembering all of the commands that you used or what their order was. - Be mindful of your base image and its size: One of the most important things to consider when creating your Dockerfile is the base image that you’re using. It will increase your Docker image's size if you have a lot of extraneous code. This will make it much slower for your container to start up or, even worse, prevent it from starting at all. The best way to avoid this is by being mindful of which packages and scripts you use. If it doesn’t seem necessary to include it in the base image, try and find a way to install it when the container starts up instead. This will save space on your container, thus making it run more quickly and efficiently.
  • 11. Dockerfile Best Practices - Do not expose secrets: Never share or copy the application credentials or any sensitive information in the Dockerfile. Instead, use the .dockerignore file to prevent copying files that might contain sensitive information. The .dockerignore file acts as equivalent to the .gitignore file, and it lets you specify the files that you want the build process to ignore. - Be mindful of which ports are exposed: When designing your Dockerfile, make sure that you know which ports are exposed. By default, Docker will expose all of the containers to a range of random internal ports. This is problematic, as it can expose critical services to the outside world and leave them open for attack. If you’re using a service that must be exposed to the public internet, then you must create an entry in the Dockerfile. This is done by adding 'EXPOSE' in your Dockerfile.
  • 12. Docker image building Best Practices Version Docker Images:A common practice among Docker users is using the latest tag for images which is also the default tag for images. Using this tag will eradicate the possibility of identifying the running version code based on the image tag. Not only does it become easier to overwrite it, but it also leads to extreme complications while doing rollbacks. Make sure to avoid using the latest tag, especially for base images, as it could unintentionally lead to the deployment of a new version. Rather than using the default tag, the best practice is to use descriptors like semantic version, timestamps, or Docker image IDs as a tag. With the practice of having a relevant tagging scheme, it becomes easier to tie the tag to the code.
  • 13. Docker image building Best Practices Avoid Storing Secrets in Images: Undeniably, confidential data or secrets like SSH keys, passwords, and TLS certificates are highly sensitive for an organization. Storing such data in images without encryption can make it easier for anyone to extract and exploit it. This situation is extremely common when images are pushed into a public registry. Rather than that, injecting these through build-time arguments, environment variables, and an orchestration tool is the best practice. In addition, sensitive data can also be added to the .dockerignore file. Another practice to accomplish this goal is by being specific about the files that should be copied over the image. Environment Variables:Environment variables are primarily used to keep the application flexible and secure. These can also be used to pass on sensitive information or secrets. However, these will still be visible in the logs, child processes, linked containers, and docker inspect. The following is a frequently used approach for managing secrets.
  • 14. Docker image building Best Practices Using a .dockerignore File: The .dockerignore file is used to define the required build context. Before an image is built, the user has to specify the files and folders that should be excluded from the initial build context sent to the Docker daemon which is done with the help of the .dockerignore file. Prior to evaluating the COPY or ADD commands, the entire project’s root is sent to the Docker daemon, making it a hefty deal. Apart from that, there can be stances when the daemon and the Docker CLI are on different machines. In that case, the .dockerignore file should be added to local secrets, temporary files, local development files, or build logs. Doing so can boost the build process, avoid secret leaks, and reduce the Docker image size. Image Linting and Scanning: Inspecting the source code for any stylistic or programmatic error that can cause issues is called lining. Linting can help ensure that the Dockerfiles comply with the right practice and can be maintained. This process can also be followed in images to determine any underlying vulnerabilities or issues.
  • 15. THANK YOU Like the Video and Subscribe the Channel