Mastering Docker
eBook - ePub

Mastering Docker

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

Russ McKendrick, Scott Gallagher

Partager le livre
  1. 426 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Mastering Docker

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

Russ McKendrick, Scott Gallagher

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Mastering Docker est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Mastering Docker par Russ McKendrick, Scott Gallagher en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Virtualisation. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2018
ISBN
9781789618686
Édition
3
Sous-sujet
Virtualisation

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...

Table des matiĂšres