Maximum PC - UK (2019-09)

(Antfer) #1
that’s done, update the package manager ( sudo apt-get update ),
then check that your system is getting Docker from the right
place by typing apt-cache policy docker-ce and scrutinizing
the results. Happy? Fire off sudo apt-get install -y docker-ce to
install the Docker Community Edition.

5


OUT OF CONTAINMENT
Docker tends to keep to itself, but it should now be installed,
and its service should be running in the background—try
sudo systemctl status docker to see if it is indeed running.
It’s important to note that the service, or daemon, is a separate
entity from the command-line tool—the service will run when
your system boots up, which means that once you’ve set up a
Docker container, it’ll stay active until you explicitly kill it. Let’s
try that now: Run sudo docker run hello-world —the command-
line app will prod the daemon, which will first check for a local
container, then (as it hasn’t found one) head to Docker’s servers,
download the “hello-world” package, add it to its own database
(allocating it the relevant storage and resources as it does so),
then run it, spewing its output [Image B] to the command line.

6


PICKING PORTS
Running a “hello world” does nothing for us, other than
prove that Docker is working, but it’s an example of how
simple it can be to get a Docker container up and running. Let’s
install something slightly more practical to show off Docker’s
power: Try running the command sudo docker run -d --name
wiki -p 8181:8080 mkodockx/docker-wiki. This tells Docker, in
order, that we want to r un something, we want it detached ( -d ) or
running in the background, we want to call the container “wiki,”
and that we want to connect TCP port 8181 on our host machine to

CD

8080 inside our container. Finally, we tell Docker where
to find the image to use for our container. Just like that,
your server is playing host to a full-blown wiki running
on top of NodeJS—all the installation, all the folder
structure, all the messing around with LAMP stacks is
done for you. One command, and it’s running. Connect to
the appropriate port of your server in a web browser (in
our case, this is 192.168.1.224:8181), and it’ll be there—
and if you wanted to run a second instance of the wiki,
just run the same command, switching out the name for,
say, “wiki2,” and connecting it to a different port. Run
sudo docker ps to see what containers you have
running [Image C].

7


TAKE IT FURTHER
So, what to do with your new-found powers?
Realistically, whatever you like. There’s a vast
catalog of tools available at http://hub.docker.com,
some of which will likely be less useful than others. That
said, you can pick up the likes of Plex (turning your server
into a media hub) [Image D], OwnCloud (for convenient
network file storage), OpenVPN (connect through your
home network from afar), and much more—and there
are other resources to check out, too, such as the
excellent http://www.linuxserver.io. We’re also running a
pair of servers for Brutal Doom via https://hub.docker.
com/r/rcdailey/zandronum-server. In this case, Docker
is handy for setup and isolation, but since the server
announces your IP address on a global browser, it does
expose you somewhat, so you’ll want to make sure your
router’s firewall is in good shape.

What’s running on your Docker box?
Given how easy it is to fire up a new
container, the answer quickly becomes
“quite a lot.” Managing those individual
software appliances is key to having an
efficient time with everything. If you’re
using the command line, typing sudo
docker ps lists all the processes that
Docker is currently managing; once
you’ve got that information, you can use
sudo docker kill followed by the
process ID to shut things down as
required. Basics of management
covered, then, but there’s much more

to it than that. Creating a “docker-
compose” file for all of your apps is
a great way to make sure they’re all
configured properly (see http://docs.
docker.com/compose for more on that)
and to run a large collection of them
with a single command. And if you want
to see what your server is up to, there’s
a number of management containers
that can help: The likes of Portainer,
Grafana, and Prometheus can help
you keep tabs on system resources
and manage running containers with a
point-and-click web interface.

CONTAINERS UPON CONTAINERS


maximumpc.com SEP 2019 MAXIMUMPC 55

Free download pdf