Getting Started with Docker

Reading time ~1 minute

Getting Started with Docker

Getting Started with Docker

1 What is Docker

Docker is an open platform for developing, shipping, and running applications.

  • What it can be used for
    • Fast, consistent delivery of applications
    • Responsive deployment and scaling
    • Running more workloads on the same hardware
  • Its architecture
    • Daemon
    • CLI and API
    • Images
    • Containers
    • Registries (Docker Hub)

2 Install and test

3 Run a command in a docker container

  • Hello world:

    docker run ubuntu:14.04 /bin/echo 'Hello world'
  • An interactive container:

    docker run -t -i ubuntu:14.04 /bin/bash
  • A daemonized hello world:

    docker run -d ubuntu:14.04 \
        /bin/sh -c "while true; do echo hello world; sleep 1; done"
    docker ps
    docker logs -f <name-of-container>
    docker stop <name-of-container>
    docker ps -a
    docker rm <name-of-container>

4 Create a web application container

  • Create a new container from ubuntu-upstart:

    docker run -d --name=webapp \
               -p 80:80 ubuntu-upstart:14.04
  • Update system packages of the container:

    alias docker-webapp-exec='docker exec -it webapp env TERM=xterm'
    docker-webapp-exec bash
    apt-get update
    apt-get -y upgrade
  • Install apache2 and mysql:

    apt-get install apache2 mysql-server php5 php5-mysql
  • Create a test app:

    cd /var/www/html/
    apt-get install vim
    vim index.php
  • Add this line on /etc/hosts.
  • Try it in browser:

5 Other docker commands

docker inspect
docker inspect --help
docker inspect ubuntu-upstart:14.04
docker inspect webapp
docker inspect -f '' webapp
docker top webapp

6 A real world example

Let's see how Docker is used by installing a B-Translator Client:

  • Get the image:

    docker search btranslator
    docker pull btranslator/btr_client:v3.0
    docker images
  • Create and start a container:

    docker create --name=btr_client \
        -p 443:443 --restart=always \
    docker ps
    docker ps -a
    docker start btr_client
  • Add this line on /etc/hosts.
  • Open in browser:

Date: 2016-10-18

Author: Dashamir Hoxha

Created: 2016-10-28 Fri 05:33

Easy GnuPG

Easy GnuPGEasy GnuPGTable of Contents1. What is GnuPG2. What is EasyGnuPG3. EasyGnuPG is opinionated4. EGPG integrates seamlessly with GP...… Continue reading

Moodle For Every School

Published on September 15, 2017