Docker Containers in Reclaim Cloud

Difficulty: Intermediate

 

We’re going to look at how to spin up a Docker container in Reclaim Cloud. Now, if you don’t know what containers are or you’re brand new to them I highly recommend stopping the video right now and watching this video: What are Containers and Cloud Hosting . It’s short and sweet and will give you a bit of a primer so you can better understand the concepts that we’ll be demonstrating here. Now that we’re on the same page, let’s get started.

So you’ve come across a project that you’d like to try hosting yourself and you’re not sure where to start, but they say they support Docker and you’ve heard that Reclaim Cloud can run Docker containers. We’re going to dive into this topic and explore all the various ways in which you can run Docker containers to host your applications on Reclaim Cloud. For my example we’ll be looking at a piece of software called Nextcloud. Nextcloud is an open source suite of software that lets you store, share, and collaborate on files (think of it like Dropbox but owned completely by you and open source). It’s a great package and lucky for you they support Docker installs so we’re going to see how we might get it up and running.

With any Docker project I can’t stress enough how important it is to read the documentation. Docker provides a standard for building packages, but the way in which packages run is very much dependent on the developer. You may need to access software on certain ports for example, or you might need a database in addition to the container for the software you’re looking at. A good Docker project will identify everything you need to start running the container as well as customizing it to your needs.

To get started let’s go to the Topology Wizard by clicking New Environment and take a look at the Docker tab. You’ll remember from other videos that Reclaim Cloud supports a variety of different programming languages with Docker being yet another option up here. When you select it the first thing we need to do is choose an image.

 

Reclaim Cloud has built in search with Docker Hub, which is a repository filled with Docker images for a variety of software. In many cases even if you found the project on Github or somewhere else, the Docker image will have been published in Docker Hub for widespread distribution. So let’s search for our project, Nextcloud.

 

And there you have it. But wait, why are there multiple images? Well, anyone is free to publish their own Docker images on Docker Hub. Perhaps they have a different take on running the software for their own needs. It’s important to make sure you trust the image you’re about to install for this reason. And if you click the More Details link here it goes straight to Docker Hub where you can read more about this particular image, who developed it, and how to run it. In this case the first result here turns out to be an official image from Docker so we can be certain it’s trustworthy. It also has a lot of documentation on using it which is excellent. Let’s use it. We’ll go back to our wizard and select that version and hit Next.

 

Now the rest of this page should look familiar if you’ve watched our previous videos on getting started with environments in Reclaim Cloud. For this project we won’t need any other elements of the stack here. However some software may require you to setup environment variables with key information, volumes to store and expose data, links to other containers, and ports to be opened and other information. If we want to adjust any of that in advance we could do so down at the bottom, but for now I’m going to click Create and just get this thing up and running and we’ll look at further customizing it afterwards.

 

 

After a few moments our installation is complete and our Docker container is up and running. Now since this is a web-based piece of software we can actually open the URL to see that Nextcloud is working.

 

Sure enough we have a getting started wizard where we can create an administrative account and start using the software. But this is not always automatic with every software. It is quite common for software projects to expose the software on different port numbers. If we go back to the documentation for this image we can see that they expose the software on port 80 and Reclaim Cloud just so happens to automatically load any software that uses port 80 as well as others. We can see the full list of ports that Reclaim Cloud will handle automatically by going to the container settings and choosing “Ports”.

 

If you need to access software on other ports that’s not a problem either, but you will need a public IP address to do so (Additional note: You can also use Endpoints to access a private port in the container which we don’t cover in this video). Right now we are on a private IP address and all of our traffic is being handled by a shared load balancer through Reclaim Cloud. You can imagine how difficult it would be to avoid conflict with all the different projects customers were running with all the various ports, so there are only a few common web-enabled ports available by default. We’re lucky in that Nextcloud is using port 80 so it’s not a problem and there are also options to tell a Docker container to use a different port. But we’ll touch more on that in a bit as we dive deeper.

Going back to these container settings we see options for VariablesLinks, and Volumes . Let’s look at what each of those mean in the context of Docker containers. Our variables are going to be environment variables that are passed on to the application. Let’s go back to, you guessed it, the documentation and see what variables we can use. I see variables here for connecting to external databases and also the ability to set an admin username and password at the time of install. If I want to add a variable to my environment I’ll go back here and simply add them in and apply. I’ll need to restart my containers for it to pick up new variables so we’ll go here and do that now.

 

 

Links are used less often these days but used to be the primary way for one container to talk to another, for example if you had a database container and needed it to host the database for an application running in another container you could setup the link between the two here. These days a lot of that happens with another concept called “Networks” in Docker terminology and the private networks that Reclaim Cloud creates in environments often allow that communication as well.

 

Volumes are another concept in the Docker world in which you may need to expose a certain folder within the container to the server that it is running on. A great example of this would be if you were running Apache in a Docker container but you needed the web-accessible folder /var/www/html to be exposed to the server so you could upload information. Looking at the Nextcloud documentation we can see they provide a lot of information on how you can use volumes to allow for persistent data from the container to the server it is running on.

 

A lot of guides you’ll find for Docker containers also provide command line arguments for running the software. Let’s look at how you might use those within Reclaim Cloud. This time instead of searching for a particular image, I’m going to create an environment that simply gives me root access with Docker pre-installed. In the Topology Wizard when I click the dropdown next to Docker I can choose Docker Engine and install.

 

Within a few minutes I have a server with root access and Docker pre-installed and ready to go. To work with this server I will need SSH keys setup in advance and connect via terminal or in this case I’ll just use the web-based SSH client built into Reclaim Cloud.

 

From our documentation on Nextcloud I should only have to run the following command to start the Docker container for that software project:

docker run -d -p 8080:80 nextcloud

Before we do let’s look at this command. It starts with the command docker run telling the system we want to run a particular image. -d means we want to run it as a “daemon” which essentially means “run this in the background so I can close the window and it stays up and running”. -p stands for ports and it’s where we can control what ports are being exposed externally to which ports internally. In this case the command is using port 8080 externally and port 80 within the container so we’re creating a bridge there to make sure we can load it on the web. We could just as easily use 80:80 here as well. We just need to be sure whatever external port we use is accessible. And then the last word there nextcloud is the specific image that is on Docker Hub. Notice I don’t have to provide any URLs. Docker will automatically know which repository to pull this image from based on name alone. When I hit enter it first checks to see if I have downloaded this image before. Since I haven’t it begins to download this image and all other images that it is dependent on.

 

 

This process can take a bit of time depending on how large and complex the software is. When it’s done we should be able to open our browser and go to the URL and port number and sure enough the software is running. Adjusting variables, links, ports, and other options can all be done here within the command line when you go to run a docker container.

 

More advanced ways of using Docker and containers including creating your own is the topic of a whole other guide, but hopefully this introduction to downloading and running Docker containers on Reclaim Cloud gives you the confidence to look at that interesting software project you have your eye on and perhaps try to get it installed.

Was this article helpful?
0 out of 0 found this helpful

Articles in this section

Reclaim Hosting Support Hours
8:00 am - 5:00 pm ET, Monday through Friday
Submit a Ticket
Get a quick and helpful response from the pros.
Need Extra Support?
No problem, we're here to help! Talk to us about Professional Services.