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)

Pushing images to Docker Hub

Here, we will create a Docker image on the local machine and push this image to Docker Hub. You need to perform the following steps in this section:

  1. Create a Docker image on the local machine by doing one of the following:
  • Using the docker commit subcommand
  • Using the docker commit subcommand with Dockerfile
  1. Pushing this created image to Docker Hub
  2. Deleting the image from Docker Hub

We will use the ubuntu base image, run the container, add a new directory and a new file, and then create a new image. In Chapter 3, Building Images, we saw how to create a Docker image using Dockerfile. You may refer to that chapter to check for details of the Dockerfile syntax.

We will run the container with the containerforhub name from the base ubuntu image, as shown in the following Terminal code:

$ sudo docker run -i --name="containerforhub" -t ubuntu /bin/bash 
Unable to find image...