Tuesday, 24 December 2019

My attempt to learn Docker



Disclaimer: This and the upcoming posts don't try to teach about Docker, they are just a record of my attempt to learn Docker

Recently heard a lot about Docker. So thought why not give it a try and here I am documenting my effort. To get some basic idea, I started by watching some basic youtube videos, I liked the tutorials by Raghav Pal (I started at video 12 btw). Since videos 12 and 13 seemed to give a pretty good idea about creating a container I felt I was ready to jump in. My idea is to try to set up a LAMP stack with apache.mysql and php containerized. Based on the videos watched I decided that I must create a separate image for each service and then run them together using docker-compose. But I didn't want to try it on my local machine since I was pretty sure I will mess it up. So created a VM in virtual box and installed lubuntu in it.

I found the installation guide here and followed the procedure to setup Docker. Most of the commands are run with sudo so I opened the terminal and ran 'sudo su' at the start

Updating the System:

I started by updating the system
apt-get update && apt-get upgrade


Install Prerequisites:

The documentation has the prerequisites that must be installed. So once the update is done I ran the following command

apt-get install  apt-transport-https  ca-certificates curl  gnupg-agent software-properties-common


Add the Docker Repo:


curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

The documents page has the commands to add the Docker repo for different architectures. Luckily mine was the one on the first (default) tab. So I added it with

add-apt-repository  "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs) stable"

Install docker:

Finally, I reached the stage where I am supposed to install Docker itself. I ran the install command to install it

apt-get install docker-ce docker-ce-cli containerd.io

and checked the version using the following command,  just to verify that it was installed indeed

docker -v

It said Docker version 19.03.5 which was the latest version. That seemed good enough since I installed it without having to reset my VM but still, it's not over yet. I have to install Docker-compose.

Install docker-compose:

I read the documentation here. And used the following command to get the file

curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose


and made it executable using

chmod +x /usr/local/bin/docker-compose

and checked the version using the following command,

docker-compose -v

It said docker-compose version 1.25.0. So I have managed to install docker and docker-compose successfully.

Next, I plan on creating an image for apache2 and run it. I will try it out and post about it.

No comments:

Post a Comment

Setting GitHub hooks in Jenkins

While setting up a Freestyle project in Jenkins we may need to set Github webhooks in Jenkins so that Jenkins will get notified each time th...