Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Docker Orchestration

You're reading from   Docker Orchestration A concise, fast-paced guide to orchestrating and deploying scalable services with Docker

Arrow left icon
Product type Paperback
Published in Jan 2017
Publisher Packt
ISBN-13 9781787122123
Length 284 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Randall Smith Randall Smith
Author Profile Icon Randall Smith
Randall Smith
Gianluca Arbezzano Gianluca Arbezzano
Author Profile Icon Gianluca Arbezzano
Gianluca Arbezzano
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Started with Docker Orchestration FREE CHAPTER 2. Building Multi-Container Applications with Docker Compose 3. Cluster Building Blocks – Registry, Overlay Networks, and Shared Storage 4. Orchestration with Docker Swarm 5. Deploying and Managing Services with Kubernetes 6. Working with Mesosphere 7. Using Simpler Orchestration Tools – Fleet and Cattle 8. Monitoring Your Cluster 9. Using Continuous Integration to Build, Test, and Deploy Containers 10. Why Stop at Containers? Automating Your Infrastructure

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.

You have been reading a chapter from
Docker Orchestration
Published in: Jan 2017
Publisher: Packt
ISBN-13: 9781787122123
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime