Mastering Docker
eBook - ePub

Mastering Docker

Unlock new opportunities using Docker's most advanced features, 3rd Edition

Russ McKendrick, Scott Gallagher

Buch teilen
  1. 426 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Mastering Docker

Unlock new opportunities using Docker's most advanced features, 3rd Edition

Russ McKendrick, Scott Gallagher

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Master Docker and leverage its power in your day-to-day workflow

Key Features

  • Explore tools such as Docker Engine, Machine, Compose, and Swarm
  • Discover how Docker can be integrated into your daily workflows
  • Learn to leverage Docker Swarm and Kubernetes

Book Description

Docker has been a game-changer when it comes to how modern applications are deployed and created. It has now grown into a key driver of innovation beyond system administration, with an impact on the world of web development. But how can you make sure you're keeping up with the innovations it's driving, or be sure you're using it to its full potential? Mastering Docker shows you how; this book not only demonstrates how to use Docker more effectively, but also helps you rethink and reimagine what's possible with it.

You will cover concepts such as building, managing, and storing images, along with best practices to make you confident, before delving more into Docker security. You'll find everything related to extending and integrating Docker in new and innovative ways. Docker Compose, Docker Swarm, and Kubernetes will help you take control of your containers in an efficient manner.

By the end of the book, you will have a broad, yet detailed, sense of what's possible with Docker, and how seamlessly it fits in with a range of other platforms and tools.

What you will learn

  • Become fluent with the basic components and concepts of Docker
  • Learn the best ways to build, store, and distribute containers
  • Understand how Docker can fit into your development workflow
  • Secure your containers and files with Docker's security features
  • Solve architectural problems using the first and third clustering tool
  • Leverage Linux containers and create highly scalable applications

Who this book is for

If you are an I.T professional and recognize Docker's importance for innovation in everything from system administration to web development, but aren't sure how to use it to its full potential, Mastering Docker is for you.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Mastering Docker als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Mastering Docker von Russ McKendrick, Scott Gallagher im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Virtualisation. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2018
ISBN
9781789618686

Managing Containers

So far, we have been concentrating on how to build, store, and distribute our Docker images. Now we are going to look at how we can launch containers, and also how we can use the Docker command-line client to manage and interact with them.
We will be revisiting the commands we used in the first chapter by going into a lot more detail, before delving deeper into the commands that are available. Once we are familiar with the container commands, we will look at Docker networks and Docker volumes.
We will cover the following topics:
  • Docker container commands:
    • The basics
    • Interacting with your containers
    • Logs and process information
    • Resource limits
    • Container states and miscellaneous commands
    • Removing containers
  • Docker networking and volumes

Technical requirements

In this chapter, we will continue to use our local Docker installation. As before, the screenshots in this chapter will be from my preferred operating system, macOS, but the Docker commands we will be running will work on all three of the operating systems on which we have installed Docker so far; however, some of the supporting commands, which will be few and far between, may be applicable only to macOS and Linux-based operating systems.
Check out the following video to see the Code in Action:
http://bit.ly/2yupP3n

Docker container commands

Before we dive into the more complex Docker commands, let's review and go into a little more detail on the commands we have used in previous chapters.

The basics

In Chapter 1, Docker Overview, we launched the most basic container of all, the hello-world container, using the following command:
$ docker container run hello-world
As you may recall, this command pulls a 1.84 KB image from the Docker Hub. You can find the Docker Store page for the image at https://store.docker.com/images/hello-world/, and as per the following Dockerfile, it runs an executable called hello:
FROM scratch
COPY hello /
CMD ["/hello"]
The hello executable prints the Hello from Docker! text to the Terminal, and then the process exits. As you can see from the full message text in the following Terminal output, the hello binary also lets you know exactly what steps have just occurred:
As the process exits, our container also stops; this can be seen by running the following command:
$ docker container ls -a
The output of the command is given here:
You may notice in the Terminal output that I first ran docker container ls with and without the -a flag—this is shorthand for --all, as running it without the flag does not show any exited containers.
We didn't have to name our container as it wasn't around long enough for us to care what it was called. Docker automatically assigns names for containers, though, and in my case, you can see that it was called pensive_hermann.
You will notice, throughout your use of Docker, that it comes up with some really interesting names for your containers if you choose to let it generate them for you. Although this is slightly off-topic, the code to generate the names can be found in names-generator.go. Right at the end of the source code, it has the following if statement:
if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
goto begin
}
This means there will never be a container called boring_wozniak (and quite rightly, too).
Steve Wozniak is an inventor, electronics engineer, programmer, and entrepreneur who co-founded Apple Inc. with Steve Jobs. He is known as a pioneer of the personal computer revolution of the 70s and 80s, and is definitely not boring!
We can remove the container with a status of exited by running the following command, making sure that you replace the name of the container with your own container name:
$ docker container rm pensive_hermann
Also, at the end of Chapter 1, Docker Overview, we launched a container using the official nginx image, using the following command:
$ docker container run -d --name nginx-test -p 8080:80 nginx
As you may remember, this downloads the image and runs it, mapping port 8080 on our host machine to port 80 on the container, and calls it nginx-test:
As you can see, running docker image ls shows us that we now have two images downloaded and also running. The following command shows us that we have a running container:
$ docker container ls
The following Terminal output shows that mine had been up for 5 minutes when I ran the command:
As you can see from our docker container run command, we introduced three flags. One of them was -d, which is shorthand for --detach. If we hadn't added this flag, then our container would have executed in the foreground, which means that our Terminal would have been frozen until we passed the process an escape command by pressing Ctrl + C.
We can see this in action by running the following command to launch a second nginx container to run alongside the container we have already launched:
$ docker container run --name nginx-foreground -p 9090:80 nginx
Once launched, open a browser and go to http://localhost:9090/. As you load the page, you will notice that your page visit is printed to the screen; hit...

Inhaltsverzeichnis