Why and How to Use Docker Instead of Base Server Utilities
Many companies use an old stack to maintain their servers and projects. Let's say they have an outdated version of Apache installed on their servers, and every few months, they need to update SSL certificates. More often than not, the only thing they do is pull changes from their git repository.
Instead, it would be better to use a Docker image to simplify the process of building, shipping, and running software applications.
What is Docker Image?
Docker is a tool that lets developers package applications and all the necessary components, like Apache, Composer, Drush, and other dependencies, into standardized units called containers that can be easily moved and run on any system that supports Docker, making application deployment more efficient and consistent across different environments.
Containers operate through images that encapsulate everything needed to run a software application, including its code, dependencies, and configuration settings, similar to an OS. Simply put, an image is a static blueprint, and a container is a runnable instance of that image.
Creating a Docker Image
Docker Hub has a repository of pre-built images. However, one can create a custom Docker image. To do that, we need to write a Dockerfile - a code file with commands that will be used in our container. Here's an example of a Dockerfile:
- FROM php:8.2-apache
- COPY . /web
- RUN composer install
- CMD [“apache2ctl”, “-D”, “FOREGROUND”]
From the base OS, we will use Apache image based on Debian.
Copy the code folder into the image and run composer install
for update packages; CMD
needs to run the command in the background.
Opigno Cloud uses Docker by default. We continuously check vulnerability versions in the Docker Container and promptly address them before creating new tags for your application (a tag corresponds to a version).
Docker images should be stored on a local host or in a special registry. A newly built image is stored in your local machine by default, meaning nobody can download this image on their machine. This is where the Docker Registry comes in.
Registries can be either public or private. If you wish to pull/download the nginx:latest
version from the public Docker Hub registry, run docker pull nginx:latest
. However, if you want to share image access only with your team of developers, you'll need to use a private registry.
Opigno LMS Docker Image
You can try out our demo Opigno LMS image by running docker pull opigno/cli:3.1.1
command to pull the image onto your local machine. Then, you can run Opigno LMS locally with docker run -p 80:8888 opigno/cli:3.1.1
command and access it through your browser at http://0.0.0.0. You should see this page:
Opigno Cloud utilizes a self-hosted GitLab Docker Registry cloud, which ensures privacy and security, limiting access to the Opigno team only.
It's worth noting that Docker images are essential for the Kubernetes Engine, a topic we will cover in our next article, so stay tuned!