Deploying Docker for first time

This article is beginner-friendly & for people starting out to get their hands dirty by docker…
According to Docker Docs, the docker is a platform for developers and sysadmins to build, run, and share applications with containers.
To be simple, the docker container can be used in building, testing & deploying any web application, with all its needed dependencies installed (or packed) within that container and it can be shared (or shipped) easily. The use of containers reduces the burden of installing all the required dependencies of the web application onto the client’s system. It also eliminates the issues regarding dependencies, where the unsupported version of supporting library is installed for that web application.
It is similar to virtual machines but the docker is functional over the shared kernel of the host system. The docker doesn’t need any dedicated resources like VMs. Enough of story-telling, lets move onto practice!
Docker installation & verification:
- Installing Docker Desktop
- Windows { https://hub.docker.com/editions/community/docker-ce-desktop-windows/ }
- Linux { cli: “sudo apt-get install docker” }
- Mac { https://hub.docker.com/editions/community/docker-ce-desktop-mac/ }
2. Testing the docker for successful installation
- Windows: Start the Docker Hub application and enter the following command, if it runs without any error then the installation is successful.
- It’s similar in Mac and Linux, so try the following command in them too.
docker run hello-world
Pulling & Working on Docker container:
The following process is nothing but downloading the docker version of ubuntu:latest in the host system & installing a LAMP server in it. The LAMP server is nothing but the web service stack which contains Apache, MySQL, PHP, etc. and other needed dependencies, which will be easier for us in case of deploying any web app on the go.
- Start with the following command, to download the docker version of Ubuntu
docker pull ubuntu
2. To see the Docker images present in the host system
docker images
3. Now try to run Ubuntu image as interactive
docker run -it ubuntu:latest
Note: The keyword ‘latest’ is a tag given to that image, which indicates the latest stable version of Ubuntu. There are also various tags for several purposes. You can view the full name of Ubuntu with tag, on using the “docker images” command.
4. Installing the LAMP server
- On running the above last command, we can get the interactive terminal of the Ubuntu Docker image. In the terminal, enter the following commands.
apt-get update -y
apt-get install lamp-server^
5. After installation, start apache service, and confirm the installation.
service apache2 start
curl http://localhost/
Note: On entering the above command, the source code of Apache default page is displayed in the terminal, which confirms the LAMP installation.
Saving LAMP Docker Image
Now we have successfully installed and configured a generic LAMP stack in an Ubuntu Docker image, but the actions performed inside docker are not autosaved. Hence we have to commit the image in order to save it.
- List the Docker containers, running on host which displays the Docker container ID of all running containers (run in host system)
docker container ls
2. Saving the LAMP Docker image
docker commit [-Lamp_Docker_ContainerID-] [-Docker_Hub_Username]:[Tag]
Note: The ‘Tag’ can be anything depends on the purpose of user. Example: latest, v1.0, minimal, stable, etc.
Conclusion
Hope, this beginner-friendly article is informative and more practical. Apologies for grammatical mistakes. Stay tuned for more such articles. Your comments and suggestions are welcomed!
Don’t forget to give it a slap or a clap! 😉
~ IRSHAD AHAMED
To be connected in both professionally & socially: