Many users face issues to get started with Docker. Here is Docker tutorial for beginners. Containers provide a service oriented easy design. Current trend is to use Virtual Machines to run software applications. That is traditional virtualisation. Inside Virtual Machines applications run inside guest Operating System with virtual BIOS, virtual hardware powered by the server’s host OS and of course hardware. So each Virtual Machine has own kernel. Xen, KVM are typical example softwares for virtualization. OpenVZ virtualization uses no separate kernel for the guest OSes and that is why compared with Xen, KVM – Xen KVM versus OpenVZ. You can read about container virtualization and Docker with Linux kernel. You need to know about few concepts around IP address, ports, code dependencies and day to day things sysadmins typical used with. This amount of theory needed to know to use Docker. Rest is on getting started basic guide. With these components Part 1 of our Docker tutorial for beginners guide.
Docker Tutorial For Beginners :
Take that we are running Ubuntu 16.04 LTS operating system. You should be an user other than root
with root privilege :
1 2 3 4 5 | sudo usermod -aG docker ${USER} su - ${USER} id -nG # optionally add <your-username> user to Docker group sudo usermod -aG docker your-username |
Of course Docker installation package available in the official repository but may not be at the latest version.To install Docker, we will run :
---
1 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
Then add the Docker repository :
1 | sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
Next we will run some expected commands :
1 2 3 4 5 | sudo apt-get update apt-cache policy docker-ce # see output similar sudo apt-get install -y docker-ce sudo systemctl status docker |
Docker installed and running. If we run :
1 | docker |
We will view all available subcommands. Command format of Docker is like :
1 | docker [option] [command] [arguments] |
hello-world
is default test application :
1 | docker run hello-world |
We can search for images on Docker Hub by using docker command, to search foo
we will run:
1 | docker search foo |
Docker Hub will return a list of all images when searched with valid name. We can download foo
in this way :
1 | docker pull foo |
then run a container using it:
1 | docker run foo |
To see the images that have been downloaded :
1 | docker images |
Let us go ahead with foo
example Docker Image. If we combine -i
and -t
we will get interactive shell access into the container as root:
1 | docker run -it ubuntu |
How you’ll use a real example like WordPress? Docker has documents for important images :
1 | https://docs.docker.com/samples/wordpress/ |