Welcome to our guide on creating a robust development environment on your Linux virtual machine! In this post you will learn how to set up a powerful environment on your Linux virtual machine by installing Docker, Docker Compose, and Portainer.
Docker simplifies the process of containerization, enabling you to package and deploy applications with ease. With Docker Compose, orchestrate multi-container Docker applications effortlessly. And with Portainer, manage your Docker environments through a user-friendly interface. Whether you’re a seasoned developer or just starting, this step-by-step guide ensures you’ll have everything you need to streamline your workflow and maximize efficiency. Let’s dive in and elevate your containerization game today!
Steps for installing Docker:
Endure you always have the latest version of Docker by updating the Ubuntu repository with the latest official version. To start, you will want to update your existing packages:
sudo apt update
Follow that command with installing the necessary apps to let APT use packages over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Once that completes you will want to add the GPG key to your system that is tied to the official Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
And then add the actual Docker repository to your APT sources list:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Run another apt update to pull in the updated list of packages:
sudo apt update
And then BAM! You are ready to install Docker:
sudo apt install docker-ce
To confirm that Docker is running, it is a good idea to check on the status of the service. You can do that with the following command where you will look to confirm the service is active:
sudo systemctl status docker
Docker is now installed! Congratulations.
Steps for installing Docker Compose:
Installing Docker Compose is a one-line command:
sudo apt install docker-compose
You are 2/3 of the way done with the tutorial now! Next step will install Portainer.
Steps for installing Portainer:
Installing Portainer is done in two steps. The first will create the volume where all data is stored for the container:
docker volume create portainer_data
The second command will download and install the Portainer Server container and start it running:
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
There is a lot going on in that last command, so I will break it down here:
docker run -d – This command is telling docker to start a new container from the image you are downloading (in this case it is Portainer)
-p 8000:8000 -p 9443:9443 – This portion of the command is specifying the ports you will use. Port 8000 is used to create a secure tunnel between the Portainer Edge Agent and The Portainer instance you are setting up. We may do a video on Edge Agents in the future as they are a great way to connect various servers without having to install the Portainer Server on each machine
–name portainer –restart=always – This portion of the command will name the container portainer for easy visibility in the application, and it tells Docker to restart the container anytime it stops or if the server reboots
-v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data – This portion of the command establishes the volume mappings. The left side of the : is the host system (in this case the docker volume we created in the first installation step above). The right side of the : maps to the path inside the actual docker container. This way the docker container can be updated without impacting any of the data the container uses.
portainer/portainer-ce:latest – This final part of the command tells what image you are downloading. in this case it is the latest version of portainer-ce
Conclusion
That’s it! You’ve successfully installed Docker, Docker Compose, and Portainer. As an example, we’ve installed NGINX Proxy Manager to test our setup. Stay tuned for more in-depth guides on Docker-compose files and other examples in future posts. Thank you for visiting the site and reading all the way to this point. I hope this guide has been helpful in empowering you with the tools to enhance your development environment! If you’re interested in what’s next for our videos, check out “What’s Next Andrew.” Happy containerizing!