Setting up Docker
TL;DR
In this article, we will:
- Get familiar with the Cockpit web interface
- Install Docker, and some Quality of Life programs
- Get a Web Server Up and Running
Loading Cockpit
At this stage, you should be able to navigate to your cockpit web interface by visiting https://(your-ip):9090
. We are using the root account with the password you set.
Info
if you are using Fedora Workstation, you may need to install cockpit first through the software store and enable the service. Cockpit provides a web interface for administrating your server.
Once you log in, you should be presented with a dashboard! We love dashboards.
Info
In a production environment, you typically do not use a root (superadmin) account. You typically don't use local authentication at all, instead authenticating with a centralized user system. However, in a single user environment the user delegation doesn't make a large difference and we will stick to administration with root.
Info
From the above, you might be able to surmise this is a hyper-v VM.
Navigate to software updates and update your software. Always a good idea when working with a fresh install. Also enable automatic software updates if you're feeling adventerous. Reboot afterwards.
Installing Pre-Requisites and Quality-of-Life Programs
Once rebooted, let's navigate to the terminal section in cockpit. Let's install some software! You can install Docker (well, technically docker's upstream moby), Docker-Compose, Micro, and Midnight Commander with the following:
Info
You can paste in the cockpit terminal with control+shift+v
Let's also set up micro for our default text editor. Paste the following in the terminal to set our profile defaults
Info
micro is a command-line based text editor that supports modern editor features, similar to VSCode or Notepad++. Micro also uses sane keyboard shortcuts (such as control+c to copy or control+q to quit). You can even use the mouse inside the console! Midnight commander is a command line based file explorer, also with mouse support (launched with mc
).
#!/bin/bash
#create the config folder for the micro text editor
mkdir -p ~/.config/micro
#set default tabs to use spaces instead, and use 2 spaces instead of 4
echo '{"tabstospaces": true, "tabsize": 2, "clipboard": "internal"}' > ~/.config/micro/settings.json
#set micro to be the default editor on login, and also in the current session
echo 'export EDITOR=micro' >> ~/.bashrc
echo 'export MC_SKIN=nicedark' >> ~/.bashrc
export EDITOR=micro
export MC_SKIN=nicedark
Hello World with Docker
Alrighty, we are now in a position to run our first docker program! The easiest container to run out of the box is a static webserver like nginx or caddy. Let's run a server now.
Navigate to http://(your-ip)
and you should have a running webserver!
Info
docker is running this container inside the terminal we have open in cockpit. This is referred to as running a program in the foreground. You can exit out of the server (closing it in the process) with control+c
Moving on
We have a basic docker installation up and running. We're not going to go into how to use docker completely: there are lots of tutorials on everything docker can do. Instead, we will jump right into the first several problems to solve:
- How do we use persistent storage and Infrastructure as Code
- How do we manage our deployment environment
- What should we do to encrypt our services
- How do we authenticate and protect our services
- How do we back up our persistent storage in an atomic matter
Let's start on that now with Designing our Workspace