DEV Community

Cover image for #025 Tips to Dockerize any web app
Omar
Omar

Posted on

#025 Tips to Dockerize any web app

Introduction

this is part 25 from the journey it's a long journey(360 day) so go please check previous parts , and if you need to walk in the journey with me please make sure to follow because I may post more than once in 1 Day but surely I will post daily at least one 😍.

And I will cover lot of tools as we move on.


Tips

tips

  1. Choose A good image
    The good image is the smallest one that make the job done , my favorite is alpine.
    there others just search for lightweight distros you will find a lot.

  2. Install only what you are going to use
    Do not install apps that you are not going to use like developement tools such as vim plugins and what ever.
    It's not only about space , also it's about security the more you use the more you make your system vulnerable for more exploits.

  3. Run containers the you want only
    Don't have multiple containers running in background that your not using , we talk before about how to stop containers.

  4. make sure to use the ports your app really want , because more ports = more ways to get into your system.

  5. make sure to every thing to be automated , so user doesn't want to excute any command in able to make that container will work perfectly , using an entrypoint that we talk about also.

  6. make sure to setup .env to store all environment variables , also we see them in postgres example.

  7. Do not save any data inside the container , instead use volumes that we talk about later . Also make sure to configure the permissions.

  8. make sure that your container send logs directly to stdout , then you can access them using

docker logs
Enter fullscreen mode Exit fullscreen mode
  1. read this website 12 factor carefully :)

End

this is the end of docker , there are more advanced later. I will make sure that I will do an full app from A to Z using all DevOps tools.
Next tool is Kubernetes! stay tuned :)

Top comments (0)