fbpx
vshosting~

Most manuals for application dockerization that you’ll find online are written for a specific language and environment. We will, however, look into general guidelines meant for virtually any type of application and show you, how to ensure their operation in Docker containers.

Base Image Selection

For issue-free operation and further simple edits and upgrades, choosing the most ideal (and author-supported) base image is critical. Considering that absolutely anyone can upload an image to the Docker Hub, it is advisable to take a close look at your selected image and make sure that it contains no malicious software or e.g. outdated library versions with security issues. 

Images labeled as “Docker certified” are a good choice for the start as that status is a certain guarantee that the image is legitimate and regularly updated. Good examples of such images are PHP or Node.js.

Furthermore, we can recommend the Bitnami company collection that contains a number of ready-made image applications and development environments. 

Additional Software Installation

Depending on the image you have chosen for your project, you can install extra software so that all prerequisites necessary for smooth application operation are fulfilled.  

The best solution is the use of a package distribution system, on which the image is based (usually Ubuntu/Debian, Alpine Linux, or CentOS). It is also very important to maintain the narrowest possible list of installed software, e.g. not install text editors, compilators, and other development tools into the containers.

Own Files in the Docker Image

You’ll also want to add your own files into the final image – be it configuration, source codes, or binary files from the app. In Dockerfile, the commands ADD or COPY are used, COPY being more transparent but not allowing for some more advanced functions such as archive unpacking into the image.

Authorization Definition

Despite it being the easiest way, avoid running the app in a container as the root user. This poses many security risks and increases the chance of container leak if the application becomes compromised or if a security error in third-party software you’re using is exploited.

Service Port Definition

If your application doesn’t use the root user or has no enhanced capabilities (CAP_NET_ADMIN), it is not possible to utilize the so-called privileged ports. (1-1024). However, that is not necessary for Docker. Use any higher port (e.g. 8080 and 8443 in place of 80/443 with a web server) and conduct port mapping via the  Docker parameters.

Running the Application in the Container

However easy it is to directly run the binary file of your application(or web server, Node.js, etc.), the much more sophisticated way is to create your own so-called entrypoint – that is a script, which will conduct the initial application configuration, can react to a variable environment etc. We can find a good example of this solution in the official PostgreSQL image.

Configuration Methods

Most applications require correct configuration to run properly. It is certainly possible to directly use a configuration file (e.g. in a mounted directory on the outside of the container) but in most cases, it is better to use a prepared entry point script, which will prepare proper configuration for running the application using a template and the variable environment of the container.

Application Data

Avoid saving data to the container filesystem – in the standard configuration, all the data will be deleted after the container is restarted. Use bind mounts (addressbook outside the container directory on the outside of the container) or mounted volume.

In addition, it is necessary to figure out how to save/send logs. The best option is certainly using centralized logging for all of your applications (ELK stack), however, even a basic  remote syslog does a good enough job.

What next?

There is always room for improvement. Beyond the scope of this article is considering different configuration management options, ELK stack for logging, application and system metrics collection via Prometheus, and the option of reaching load balancing and high-availability for your application using Kubernetes – which at vshosting~, we will gladly build for you and tailor it to your application’s needs 🙂


vshosting~

Why website loading speed matters

Do you want to get as many visitors to your website as possible and have them stay there for a while? Then you need to make your site as fast as possible. Loading speed is one of the factors that affect how a site ranks in search results. In addition, the slow loading of the website is the main reason why visitors who have already reached the website will leave again quickly. And what if a slow or even broken website damages your business?

In addition, users are increasingly accessing the web from mobile devices, where slow loading is even more noticeable (and annoying) than on desktop.

Studies show that:

– 47% of users expect the page to load in 2 seconds
– 40% of users leave after 3 seconds of loading
– 46% of online users decide whether to return to the site based on its speed
– an optimized site should load within 3 seconds

How fast is your website?

Step 1 is figuring out whether you really have a problem with website loading speed. You’ll be able to assess that by using any of the following tools:

If you get a result of 3-second loading speed or more, we recommend you take a good look at why that is the case. There are many factors that can affect website speed. Here are the most common ones.

Major website slowers

Excessive website size

The larger the page, the longer it takes to load. The ideal page size is up to 3MB. Page size is affected by the number of images, videos, fonts, styles, and other graphic elements. If you have more than one image on the web, focus on compressing them. This can be facilitated by a wide range of plugins, such as Smush for WordPress.

No caching

Proper caching can effectively speed up the web. Caching is, simply put, the storage of information in specialized repositories, from where it is possible to work with them quickly, and therefore it does not have to be retrieved from remote servers.

One of the options is making use of a CDN. CDN is a network for faster content delivery. It helps speed up websites by storing static content (images, videos, HTML code,…) in key locations, reducing the distance between a visitor to your site and the server running the site. In addition, CDN storage works on the basis of fast SSD disks, thanks to which they not only provide a closer distribution of content to your users but also help in the speed of loading this content.

Too many HTTP requests

In order for a visitor to load your site at all, the visitor’s computer must establish a connection with the server on which your site is running. A large amount of data needed to display the site properly begins to flow through this connection. The more elements (images, icons, styles, javascript, etc.) you have on the website, the more connections must be established and the longer it takes.

The solution is to switch to HTTP/2. Unlike older versions of HTTP, which communicated in text form, HTTP/2 is binary and allows many more requests to be transmitted over a single connection. When switching to HTTP/2, there is an acceleration in the order of 100ms to 1 second.

We recommend that you ask your hosting provider if they support HTTP/2 and if your site also runs on HTTP/2.

Outdated application versions

Outdated versions of applications can slow down and even jeopardize your site. A large number of websites are programmed in PHP. However, there are big differences between the older version of the language (PHP 5) and the new version of PHP 7. The performance difference can be up to 50% and some functions in the newer version of PHP 7 are many times faster.

It is also very important to update the content management system and its plugins. An out-of-date content management system means a high-security risk.

Inappropriate hosting location

The more remote the server on which the site runs is, the more connections must be established and the more complex the overhead and the number of queries. For remote hostings, the communication speed can be in the order of tens of 100ms. So choose hosting that is close to the site visitors or use CDN, which we mention in one of the previous points.

Lack of readiness for traffic spikes

You’ve launched a campaign, a special promotion, or are running an ad on TV. A wave of visitors from various marketing channels is heading to your website. You’ve optimized everything for the most conversions and look forward to great results.
But have you thought about whether your site can handle it? Traffic spikes are great for your business as long as the hosting works as it should.

The fact that the website does not withstand high traffic is often caused by neglect of hosting preparations. Most often, the performance of hosting is underestimated and during peak hours it cannot handle multiple requests to view the website. Make sure your hosting provider is ready for peak hours. They should have a performance reserve and sufficient line capacity.

In addition to hosting, you also need to look directly at the application (your e-shop, catalog, website) and optimize the database. Make sure that the application does not make unnecessarily many queries to the database and that it does not happen to store content that does not belong in the database.

Summing things up

Website and e-shop operators often focus primarily on creating and caring for site content and optimizing the marketing funnel. However, their work can be ruined by hosting that is not optimized for speed, reliability, and security.

Although the cost of hosting is not one of the main items in the business, it is hosting that can ruin all the effort and plans. Therefore, it is necessary to host your website or e-shop with a quality provider who can advise and has tools for the smooth running of your business.


We have successfully assisted with migrations for hundreds of clients over the course of 17 years. Join them.

  1. Schedule a consultation

    Simply leave your details. We’ll get back to you as soon as possible.

  2. Free solution proposal

    A no commitment discussion about how we can help. We’ll propose a tailored solution.

  3. Professional implementation

    We’ll create the environment for a seamless migration according to the agreed proposal.

Leave us your email or telephone number




    Or contact us directly

    +420 246 035 835 Available 24/7
    consultation@vshosting.eu
    Copy
    We'll get back to you right away.