Book Image

Docker Orchestration

By : Randall Smith
Book Image

Docker Orchestration

By: Randall Smith

Overview of this book

Docker orchestration is what you need when transitioning from deploying containers individually on a single host to deploying complex multi-container apps on many machines. This book covers the new orchestration features of Docker 1.12 and helps you efficiently build, test, and deploy your application using Docker. You will be shown how to build multi-container applications using Docker Compose. You will also be introduced to the building blocks for multi-host Docker clusters such as registry, overlay networks, and shared storage using practical examples. This book gives an overview of core tools such as Docker Machine, Swarm, and Compose which will enhance your orchestration skills. You’ll learn how to set up a swarm using the decentralized building block. Next, you’ll be shown how to make the most out of the in-built orchestration feature of Docker engine and you’ll use third-party tools such as Kubernetes, Mesosphere, and CoreOS to orchestrate your existing process. Finally, you will learn to deploy cluster hosts on cloud services and automate your infrastructure.
Table of Contents (17 chapters)
Docker Orchestration
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Inspecting your container


There comes a time in the life of anyone working with containers when you will need to jump into a running container and see what is going on. Fortunately, Docker has just the tool for you in the form of docker exec. The exec subcommand takes two arguments, the name of the container, and the command to run:

$ docker exec -it nginx bash

I slipped an option in there that is important if you are starting an interactive process. The -it option tells Docker that you have an interactive process and that you want a new TTY. This is essential if you want to start a shell:

$ sudo docker exec -it nginx bash                                                                
root@fd8533fa2eda:/# ps ax
PID TTY      STAT   TIME COMMAND
1 ?        Ss     0:00 nginx: master process nginx -g daemon off;
6 ?        S      0:00 nginx: worker process
13 ?        Ss     0:00 bash
18 ?        R+     0:00 ps ax
root@fd8533fa2eda:/# exit

In the preceding example, I connected to the container and ran ps ax to see every process that the container knew about. Getting a shell in the container can be invaluable when debugging. You can verify that files were added correctly or that internal scripts are properly handling environment variables passed in through docker.

It's also possible to run non-interactive programs. Let's use the same ps example as earlier:

$ sudo docker exec nginx ps ax           
PID TTY      STAT   TIME COMMAND
1 ?        Ss     0:00 nginx: master process nginx -g daemon off;
6 ?        S      0:00 nginx: worker process
19 ?        Rs     0:00 ps ax

As you might expect, there's not much to see here, but it should give you an idea of what is possible. I often use them when debugging and I do not need a full shell.