Book Image

Learning Docker - Second Edition

By : Vinod Singh, Pethuru Raj, Jeeva S. Chelladhurai
Book Image

Learning Docker - Second Edition

By: Vinod Singh, Pethuru Raj, Jeeva S. Chelladhurai

Overview of this book

Docker is an open source containerization engine that offers a simple and faster way for developing and running software. Docker containers wrap software in a complete filesystem that contains everything it needs to run, enabling any application to be run anywhere – this flexibily and portabily means that you can run apps in the cloud, on virtual machines, or on dedicated servers. This book will give you a tour of the new features of Docker and help you get started with Docker by building and deploying a simple application. It will walk you through the commands required to manage Docker images and containers. You’ll be shown how to download new images, run containers, list the containers running on the Docker host, and kill them. You’ll learn how to leverage Docker’s volumes feature to share data between the Docker host and its containers – this data management feature is also useful for persistent data. This book also covers how to orchestrate containers using Docker compose, debug containers, and secure containers using the AppArmor and SELinux security modules.
Table of Contents (13 chapters)

The docker exec command

The docker exec command provides the much-needed help to users, who are deploying their own web servers or have other applications running in the background. Now, it is not necessary to log in to run the SSH daemon in the container.

  1. First, create a Docker container:
      $ sudo docker run --name trainingapp \  
training/webapp:latest
Unable to find image
'training/webapp:latest' locally
latest: Pulling from training/webapp
9dd97ef58ce9: Pull complete
a4c1b0cb7af7: Pull complete
Digest: sha256:06e9c1983bd6d5db5fba376ccd63bfa529e8d02f23d5079b8f74a616308fb11d
Status: Downloaded newer image for
training/webapp:latest
  1. Next, run the docker ps -a command to get the container ID:
      $ sudo docker ps -a
a245253db38b training/webapp:latest
"python app.py"
  1. Then, run the docker exec command to log...