Book Image

Developing with Docker

By : Jaroslaw Krochmalski, Jarosław Krochmalski
Book Image

Developing with Docker

By: Jaroslaw Krochmalski, Jarosław Krochmalski

Overview of this book

This fast-paced practical guide will get you up and running with Docker. Using Docker, you will be able to build, ship, and run many distributed applications in real time. You will start with quickly installing Docker and start working with images and containers. We will present different types of containers and their applications, and show you how to find and build images. You will learn how you can contribute to the image repository by publishing different images. This will familiarize you with the image building process and you will be able to successfully run your programs within containers. By finishing this book, you will be well equipped in deploying your applications using Docker and will have a clear understanding of concepts, techniques, and practical methods to get it running in production systems.
Table of Contents (16 chapters)
Developing with Docker
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Executing arbitrary commands with exec


It's maybe the most powerful all--around tool when working with Docker images. The exec command allows you to run arbitrary commands inside a running container.

In opposite of the overriding the CMD or ENTRYPOINT, the command started using docker exec will only run while the container's primary process (PID 1) is running.

Tip

If the container is paused, then the docker exec command will fail with an error.

Also, the syntax of the exec command is different. It's not a part of the Docker run command, it's rather a new separate command, executed after you run your container with the docker run. Consider the following example and run the following in one shell terminal:

docker run -it ubuntu bash --name myUbuntuBash

Then run the next command in the second shell terminal window:

dockerexec -d myUbuntuBash touch /tmp/myFile

In the preceding example, the first command fill starts the interactive bash shell from the Ubuntu container, ok that is nothing new; however...