Docker for devs with hands-on| Part-3

  • Need of the docker.
  • Delivery of Apps in traditional & modern world.
  • Basics of docker, images, containers.
  • Enhancing docker container by installing custom softwares.
  • Launch custom Docker-Image from an existing docker container.
  • Sometimes, we might end up using different spring profiles like development, qa, uat, etc for different environments.
  • Sometimes, the application needs Tomcat to run, but Tomcat won’t start because it’s not correctly configured for your machine.
  • Sometimes, you realize that you haven’t installed the correct Java development kit or you’ve got the wrong version of the JDK. E.g. The application was originally developed on Java 7 and yet we’ve installed Java 1.8.5_12 and the two versions are a mismatch.
  • Say, the application depends on MySQL being installed on this machine. And so you have to install MySQL and then you’ve got to configure the security in the ports.
  • And I’m going on and on and on.
  • A fully configured Java virtual machine.
  • A configured tomcat.
  • Some kind of front end proxy server such as Nginx or Apache.
  • A war file inside that container.
  • And the container can also contain all of the necessary environment variables and configurations that container needs to run.
  • A container is an instance of an image and you instantiate one of these images by simply running. The difference between an image and a container, the image is the entity that we build. And when we run that image, it will become a container at runtime.
  • So, that means you could take a single image and you could run it multiple times, in which case you would end up with multiple containers all running the same image.
  • When we launch a container, the container is running on top of your host operating systems kernel. And actually, the container is actually just a process running on your kernel.
  • So, although a container might feel like a full virtual machine. It’s not a full virtual machine because it doesn’t contain its own operating system.
docker image pull ubuntu
docker container run ubuntu
docker container run -it ubuntu
apt-get update && apt-get install git
docker container ls -a
docker container start 98ff2ff01546
docker container logs 98ff2ff01546
docker container logs -f 98ff2ff01546
docker container exec -it <container_id> bash
apt-cache search jdk
apt-get update && apt-get install -y openjdk-8-jdk
javac -version
  • The changes we make, if any, in this container are going to be transient when we stop and remove that container. Those changes would be gone.
  • But actually, you can take a snapshot of a running container i.e. we’ll take an image from that running container. Below is the command to form the brand new image from the enhanced container.
docker container commit -a “Ubuntu + JDK + Git image” 98 ubuJdkGitAdityaImage
docker container stop 98
docker container ls -a
docker container rm <container_id>
docker container ls -a
docker images
docker container run -it ubu-jdk-git-aditya-image
  • We had ran the container with “-i” option which means interactive mode.
  • We had ran the container with “-t” option which means, we shall connect to the container’s terminal as well.
  • In the fresh container that we just launched, observe that both GIT & JDK are already installed, as we did the same in it’s previous container from which we formed this image.
docker container ls -a
docker container start <container_id>
docker container exec -it <container_id> bash

--

--

--

Software Engineer for Big Data distributed systems

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Swift Solutions: Bridge

Welcome to HackGuild!

Illustration by Sara Georgas

Grocery Store Rush Hour Customer Arrival Simulation

How to profit from Burning and Staking on ROCKI

The Little Tech Podcast

SMART APPLICATION TO SUPPORT PEOPLE WITH HEARING DISABILITIES AND SPEECH IMPEDIMENTS.

Integrating Flutter into an Existing App — Part One: Flutter with Submodules

Simple CRUD application in laravel 5.8 Part-1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
aditya goel

aditya goel

Software Engineer for Big Data distributed systems

More from Medium

Docker for devs with hands-on| Part-4

Getting Started with Docker — Part 01

Local Development Set-Up of PostgreSQL with Docker

Jenkins error — Starting Jenkins /etc/rc.d/init.d/jenkins: line 115: img-src: command not found

Jenkins error - Starting Jenkins /etc/rc.d/init.d/jenkins: line 115: img-src: command not found