Embrace the Docker Revolution in 3 Easy Steps
The concept of containers is not new in computing, but over the past few years Docker has made tremendous strides to simplify how we use them in our day-to-day server administration. You can isolate an application into a single container and rest assured that everything needed to help make it run is present.
Instead of applications and services being installed on a number of different operating systems, you can now package them into containers, ready to be massively deployed, near-regardless of the underlying hardware or specifications.
Imagine a Docker container as similar to a virtual machine, where it can easily be moved digitally between different physical sets of hardware. However, you can have multiple Docker containers running on a single virtual machine. This increase in flexibility opens up many more options than you previously had and offers additional control over your infrastructure.
Install Docker on Your Virtual Machine
Setting up Docker is as easy as pulling an installation script directly from Docker itself. The following command is compatible with Debian and Ubuntu, and directions for other distributions can be found here.
To get started, run this command on your Linode server over SSH:
curl -sSL https://get.docker.com/ | sh
If using an unrestricted user, you’ll want to then add it to the Docker user group with the following command:
sudo usermod -aG docker example_user
Download and Run Docker Images
Now with Docker installed, you’re ready to download images and run them. You can explore available images online at https://hub.docker.com/explore/. For this tutorial, we’ll be using a Linode-supplied guide for a LAMP stack, a great way to start any new site.
You’ll first need to search for our LAMP image before pulling it. To do this, run the following two commands in this order:
sudo docker search linode
sudo docker pull linode/lamp
After the image downloads, you’ll need to start it. The following command will run the image, passing requests on port 80 to it:
sudo docker run -p 80:80 -t -i linode/lamp /bin/bash
Once the LAMP stack is running inside the container, you can start your Apache and MySQL services with these two commands:
service apache2 start
service mysql start
Expanding on Docker
Using containers is a powerful method by which to create your own templates that can be instantly deployed in individual or massive quantities. Following the instructions above, you were able to select a premade image and immediately use a full LAMP stack without installing any of it. That’s how Docker basics work and that’s the power of containers.
In addition, the entire process of downloading and running a Docker image can be automated. Coupling this with our StackScript feature, you can write a script that downloads a particular Docker image and sets it up — automatically!
See what you can do with Docker on a Linode, and let us know how it can help improve your infrastructure performance. If you found this information helpful, please share. For more information on containers, visit our library at: https://www.linode.com/docs/applications/containers/