02-14-2019, 06:57 PM
Make Container Management Easy With Cockpit
<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/make-container-management-easy-with-cockpit.jpg" width="1733" height="1005" title="" alt="" /></div><div><div><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/make-container-management-easy-with-cockpit.jpg" class="ff-og-image-inserted" /></div>
<p><strong><span><span>Learn how to use Cockpit for Linux administration tasks in this tutorial from our archives.</span></span></strong></p>
<p><span><span>If you administer a Linux server, you’ve probably been in search of a solid administration tool. That quest has probably taken you to such software as </span><a href="http://www.webmin.com/"><span>Webmin</span></a><span> and </span><a href="http://cpanel.com/"><span>cPanel</span></a><span>. But if you’re looking for an easy way to manage a Linux server that also includes Docker, one tool stands above the rest for that particular purpose: </span><a href="http://cockpit-project.org/"><span>Cockpit</span></a><span>.</span></span></p>
<p><span><span>Why Cockpit? Because it includes the ability to handle administrative tasks such as:</span></span></p>
<ul>
<li>
<p><span><span>Connect and manage multiple machines</span></span></p>
</li>
<li>
<p><span><span>Manage containers via Docker</span></span></p>
</li>
<li>
<p><span><span>Interact with a Kubernetes or Openshift clusters</span></span></p>
</li>
<li>
<p><span><span>Modify network settings</span></span></p>
</li>
<li>
<p><span><span>Manage user accounts</span></span></p>
</li>
<li>
<p><span><span>Access a web-based shell</span></span></p>
</li>
<li>
<p><span><span>View system performance information by way of helpful graphs</span></span></p>
</li>
<li>
<p><span><span>View system services and log files</span></span></p>
</li>
</ul>
<p><span><span>Cockpit can be installed on </span><a href="https://www.debian.org/"><span>Debian</span></a><span>, </span><a href="https://www.redhat.com/en"><span>Red Hat</span></a><span>, </span><a href="https://www.centos.org/"><span>CentOS</span></a><span>, </span><a href="https://www.archlinux.org/"><span>Arch Linux</span></a><span>, and </span><a href="https://www.ubuntu.com/"><span>Ubuntu</span></a><span>. Here, I will focus on installing the system on a Ubuntu 16.04 server that already includes Docker.</span></span></p>
<p><span><span>Out of the list of features, the one that stands out is the container management. Why? Because it make installing and managing containers incredibly simple. In fact, you might be hard-pressed to find a better container management solution.</span></span><br class="kix-line-break" /><span><span>With that said, let’s install this solution and see just how easy it is to use.</span></span></p>
<h3><span><span>Installation</span></span></h3>
<p><span><span>As I mentioned earlier, I will be installing Cockpit on an instance of Ubuntu 16.04, with Docker already running. The steps for installation are quite simple. The first thing you must do is log into your Ubuntu server. Next you must add the necessary repository with the command:</span></span></p>
<pre>
<span><span>sudo add-apt-repository ppa:cockpit-project/cockpit</span></span></pre>
<p><span><span>When prompted, hit the Enter key on your keyboard and wait for the prompt to return. Once you are back at your bash prompt, update apt with the command:</span></span></p>
<pre>
<span><span>sudo apt-get get update</span></span></pre>
<p><span><span>Install Cockpit by issuing the command:</span></span></p>
<pre>
<span><span>sudo apt-get -y install cockpit cockpit-docker</span></span></pre>
<p><span><span>After the installation completes, it is necessary to start the Cockpit service and then enable it so it auto-starts at boot. To do this, issue the following two commands:</span></span></p>
<pre>
<span><span>sudo systemctl start cockpit</span>
<span>sudo systemctl enable cockpit</span></span></pre>
<p><span><span>That’s all there is to the installation.</span></span></p>
<h3><span><span>Logging into Cockpit</span></span></h3>
<p><span><span>To gain access to the Cockpit web interface, point a browser (that happens to be on the same network as the Cockpit server) to http://IP_OF_SERVER:9090, and you will be presented with a login screen (</span><span>Figure 1</span><span>).</span></span></p>
<p><span><span>A word of warning with using Cockpit and Ubuntu. Many of the tasks that can be undertaken with Cockpit require administrative access. If you log in with a standard user, you won’t be able to work with some of the tools like Docker. To get around that, you can enable the root user on Ubuntu. This isn’t always a good idea. By enabling the root account, you are bypassing the security system that has been in place for years. However, for the purpose of this article, I will enable the root user with the following two commands:</span></span></p>
<pre>
<span><span>sudo passwd root</span></span> <span><span>sudo passwd -u root </span></span></pre>
<p><span><span>NOTE: Make sure you give the root account a very challenging password.</span></span></p>
<p><span><span>Should you want to revert this change, you only need issue the command:</span></span></p>
<pre>
<span><span>sudo passwd -l root</span></span></pre>
<p><span><span>With other distributions, such as CentOS and Red Hat, you will be able to log into Cockpit with the username<em> </em></span><em><span>root</span></em><span><em> </em>and the root password, without having to go through the extra hopes as described above.</span></span><br class="kix-line-break" /><span><span>If you’re hesitant to enable the root user, you can always pull down the images, from the server terminal (using the command </span><em><span>docker pull IMAGE_NAME w</span></em><span>here</span><em><span> </span></em><span><em>IMAGE_NAME</em> </span><span>is the image you want to pull). That would add the image to your docker server, which can then be managed via a regular user. The only caveat to this is that the regular user must be added to the Docker group with the command:</span></span></p>
<pre>
<span><span>sudo usermod -aG docker USER</span></span></pre>
<p><span><span>Where USER is the actual username to be added to the group. Once you’ve done that, log out, log back in, and then restart Docker with the command:</span></span></p>
<pre>
<span><span>sudo service docker restart</span></span></pre>
<p><span><span>Now the regular user can start and stop the added Docker images/containers without having to enable the root user. The only caveat is that user will not be able to add new images via the Cockpit interface.</span></span></p>
<p><span><span>Using Cockpit</span></span></p>
<p><span><span>Once you’ve logged in, you will be treated to the Cockpit main window (</span><span>Figure 2</span><span>). </span></span></p>
<p><span><span>You can go through each of the sections to check on the status of the server, work with users, etc., but we want to go right to the containers. Click on the Containers section to display the current running contains as well as the available images (</span><span>Figure 3</span><span>).</span></span></p>
<p><span><span>To start an image, simply locate the image and click the associated start button. From the resulting popup window (</span><span>Figure 4</span><span>), you can check all the information about the image (and adjust as needed), before clicking the Run button.</span></span></p>
<p><span><span>Once the image is running, you can check its status by clicking on the entry under the Containers section and then Stop, Restart, or Delete the instance. You can also click Change resource limits and then adjust either the Memory limit and/or CPU priority.</span></span></p>
<h3><span><span>Adding new images</span></span></h3>
<p><span><span>Say you have logged on as the root user. If so, you can add new images with the help of the Cockpit GUI. From the Containers section, click the Get new image button and then, in the resulting window, search for the image you want to add. Say you want to add the latest official build of Centos. Type </span><span>centos</span><span> in the search field and then, once the search results populate, select the official listing and click Download (</span><span>Figure 5</span><span>).</span></span></p>
<p><span><span>Once the image has downloaded, it will be available to Docker and can be run via Cockpit.</span></span></p>
<h3><span><span>As simple as it gets</span></span></h3>
<p><span><span>Managing Docker doesn’t get any easier. Yes, there is a caveat when working with Cockpit on Ubuntu, but if it’s your only option, there are ways to make it work. With the help of Cockpit, you can not only easily manage Docker images, you can do so from any web browser that has access to your Linux server. Enjoy your newfound Docker ease.</span></span></p>
</div>
<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/make-container-management-easy-with-cockpit.jpg" width="1733" height="1005" title="" alt="" /></div><div><div><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/make-container-management-easy-with-cockpit.jpg" class="ff-og-image-inserted" /></div>
<p><strong><span><span>Learn how to use Cockpit for Linux administration tasks in this tutorial from our archives.</span></span></strong></p>
<p><span><span>If you administer a Linux server, you’ve probably been in search of a solid administration tool. That quest has probably taken you to such software as </span><a href="http://www.webmin.com/"><span>Webmin</span></a><span> and </span><a href="http://cpanel.com/"><span>cPanel</span></a><span>. But if you’re looking for an easy way to manage a Linux server that also includes Docker, one tool stands above the rest for that particular purpose: </span><a href="http://cockpit-project.org/"><span>Cockpit</span></a><span>.</span></span></p>
<p><span><span>Why Cockpit? Because it includes the ability to handle administrative tasks such as:</span></span></p>
<ul>
<li>
<p><span><span>Connect and manage multiple machines</span></span></p>
</li>
<li>
<p><span><span>Manage containers via Docker</span></span></p>
</li>
<li>
<p><span><span>Interact with a Kubernetes or Openshift clusters</span></span></p>
</li>
<li>
<p><span><span>Modify network settings</span></span></p>
</li>
<li>
<p><span><span>Manage user accounts</span></span></p>
</li>
<li>
<p><span><span>Access a web-based shell</span></span></p>
</li>
<li>
<p><span><span>View system performance information by way of helpful graphs</span></span></p>
</li>
<li>
<p><span><span>View system services and log files</span></span></p>
</li>
</ul>
<p><span><span>Cockpit can be installed on </span><a href="https://www.debian.org/"><span>Debian</span></a><span>, </span><a href="https://www.redhat.com/en"><span>Red Hat</span></a><span>, </span><a href="https://www.centos.org/"><span>CentOS</span></a><span>, </span><a href="https://www.archlinux.org/"><span>Arch Linux</span></a><span>, and </span><a href="https://www.ubuntu.com/"><span>Ubuntu</span></a><span>. Here, I will focus on installing the system on a Ubuntu 16.04 server that already includes Docker.</span></span></p>
<p><span><span>Out of the list of features, the one that stands out is the container management. Why? Because it make installing and managing containers incredibly simple. In fact, you might be hard-pressed to find a better container management solution.</span></span><br class="kix-line-break" /><span><span>With that said, let’s install this solution and see just how easy it is to use.</span></span></p>
<h3><span><span>Installation</span></span></h3>
<p><span><span>As I mentioned earlier, I will be installing Cockpit on an instance of Ubuntu 16.04, with Docker already running. The steps for installation are quite simple. The first thing you must do is log into your Ubuntu server. Next you must add the necessary repository with the command:</span></span></p>
<pre>
<span><span>sudo add-apt-repository ppa:cockpit-project/cockpit</span></span></pre>
<p><span><span>When prompted, hit the Enter key on your keyboard and wait for the prompt to return. Once you are back at your bash prompt, update apt with the command:</span></span></p>
<pre>
<span><span>sudo apt-get get update</span></span></pre>
<p><span><span>Install Cockpit by issuing the command:</span></span></p>
<pre>
<span><span>sudo apt-get -y install cockpit cockpit-docker</span></span></pre>
<p><span><span>After the installation completes, it is necessary to start the Cockpit service and then enable it so it auto-starts at boot. To do this, issue the following two commands:</span></span></p>
<pre>
<span><span>sudo systemctl start cockpit</span>
<span>sudo systemctl enable cockpit</span></span></pre>
<p><span><span>That’s all there is to the installation.</span></span></p>
<h3><span><span>Logging into Cockpit</span></span></h3>
<p><span><span>To gain access to the Cockpit web interface, point a browser (that happens to be on the same network as the Cockpit server) to http://IP_OF_SERVER:9090, and you will be presented with a login screen (</span><span>Figure 1</span><span>).</span></span></p>
<p><span><span>A word of warning with using Cockpit and Ubuntu. Many of the tasks that can be undertaken with Cockpit require administrative access. If you log in with a standard user, you won’t be able to work with some of the tools like Docker. To get around that, you can enable the root user on Ubuntu. This isn’t always a good idea. By enabling the root account, you are bypassing the security system that has been in place for years. However, for the purpose of this article, I will enable the root user with the following two commands:</span></span></p>
<pre>
<span><span>sudo passwd root</span></span> <span><span>sudo passwd -u root </span></span></pre>
<p><span><span>NOTE: Make sure you give the root account a very challenging password.</span></span></p>
<p><span><span>Should you want to revert this change, you only need issue the command:</span></span></p>
<pre>
<span><span>sudo passwd -l root</span></span></pre>
<p><span><span>With other distributions, such as CentOS and Red Hat, you will be able to log into Cockpit with the username<em> </em></span><em><span>root</span></em><span><em> </em>and the root password, without having to go through the extra hopes as described above.</span></span><br class="kix-line-break" /><span><span>If you’re hesitant to enable the root user, you can always pull down the images, from the server terminal (using the command </span><em><span>docker pull IMAGE_NAME w</span></em><span>here</span><em><span> </span></em><span><em>IMAGE_NAME</em> </span><span>is the image you want to pull). That would add the image to your docker server, which can then be managed via a regular user. The only caveat to this is that the regular user must be added to the Docker group with the command:</span></span></p>
<pre>
<span><span>sudo usermod -aG docker USER</span></span></pre>
<p><span><span>Where USER is the actual username to be added to the group. Once you’ve done that, log out, log back in, and then restart Docker with the command:</span></span></p>
<pre>
<span><span>sudo service docker restart</span></span></pre>
<p><span><span>Now the regular user can start and stop the added Docker images/containers without having to enable the root user. The only caveat is that user will not be able to add new images via the Cockpit interface.</span></span></p>
<p><span><span>Using Cockpit</span></span></p>
<p><span><span>Once you’ve logged in, you will be treated to the Cockpit main window (</span><span>Figure 2</span><span>). </span></span></p>
<p><span><span>You can go through each of the sections to check on the status of the server, work with users, etc., but we want to go right to the containers. Click on the Containers section to display the current running contains as well as the available images (</span><span>Figure 3</span><span>).</span></span></p>
<p><span><span>To start an image, simply locate the image and click the associated start button. From the resulting popup window (</span><span>Figure 4</span><span>), you can check all the information about the image (and adjust as needed), before clicking the Run button.</span></span></p>
<p><span><span>Once the image is running, you can check its status by clicking on the entry under the Containers section and then Stop, Restart, or Delete the instance. You can also click Change resource limits and then adjust either the Memory limit and/or CPU priority.</span></span></p>
<h3><span><span>Adding new images</span></span></h3>
<p><span><span>Say you have logged on as the root user. If so, you can add new images with the help of the Cockpit GUI. From the Containers section, click the Get new image button and then, in the resulting window, search for the image you want to add. Say you want to add the latest official build of Centos. Type </span><span>centos</span><span> in the search field and then, once the search results populate, select the official listing and click Download (</span><span>Figure 5</span><span>).</span></span></p>
<p><span><span>Once the image has downloaded, it will be available to Docker and can be run via Cockpit.</span></span></p>
<h3><span><span>As simple as it gets</span></span></h3>
<p><span><span>Managing Docker doesn’t get any easier. Yes, there is a caveat when working with Cockpit on Ubuntu, but if it’s your only option, there are ways to make it work. With the help of Cockpit, you can not only easily manage Docker images, you can do so from any web browser that has access to your Linux server. Enjoy your newfound Docker ease.</span></span></p>
</div>