Debug School

Jawahar Lal Soni
Jawahar Lal Soni

Posted on

Day 2 Docker Assignment

How to Develop an Image

  1. Run a Container in itd mode with ubuntu image docker run -itd ubuntu
  2. Go into the container with execute command.
    docker exec -it 2cfdc788d068 /bin/bash

  3. Install Java
    Download and Install JDK/JRE 11 in Ubuntu
    apt-get update
    apt-get install openjdk-11-jdk -y
    apt install openjdk-11-jdk-headless -y

  4. Install Apache2
    Command – apt-get install apache2 -y

  5. Exit from Container

  6. Search and download Sample.war file and click on the link -> copy link address.

We can see sample.war file is available.

  1. Install wget command and provide permission.
    Command - yum install wget -y

  2. Copy the sample.war file to the container.
    Command: docker cp sample.war 2cfdc788d068:/opt

  3. Validate we have everything we require.
    Like – Java, Apache2, Sample.war
    $ docker exec 2cfdc788d068 java

  4. Commit – create the image
    $docker commit -m"ub-java-apache2-app" -a"jawahar" 2cfdc788d068 managerapp

  5. Create the container from the image
    $docker run -itd --name manager managerapp

  6. Verify everything we require is there in container “manager”
    $ docker exec manager java

$ docker exec manager which apache2
$ docker exec manager ls /opt

How to share the image

  1. Create a tarball file
    $ docker save -o managerapp.tar managerapp

  2. Load Image
    $docker load -i managerapp.tar

Share the image with Team – Docker Registry.

  1. Create a registry on docker hub
    jawahar108/devopsmanagerapp general | Docker Hub

  2. Login to with your docker user name and password.
    $ docker login

  3. Tag Docker Images or Alias the image
    $ docker tag managerapp jawahar108/devopsmanagerapp

  4. Push the image to docker
    $ docker push jawahar108/devopsmanagerapp

Refresh the docker and click on Public View

jawahar108/devopsmanagerapp - Docker Image | Docker Hub
Docker Pull Command
docker pull jawahar108/devopsmanagerapp

Share the url with manager.
jawahar108/devopsmanagerapp - Docker Image | Docker Hub

Thank You!

Top comments (0)