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 '{ { .NetworkSettings.IPAddress }}' 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: 2019-01-24 Thu 05:13

Emacs 25.1.1 (Org mode 8.2.10)


OpenPGP Web Key Directory

OpenPGP Web Key DirectoryOpenPGP Web Key DirectoryTable of Contents1. Introduction2. How WKD works3. Building a WKD3.1. Create the direct...… Continue reading

SMTP Server with LDAP Authentication

Published on April 17, 2021

Using WireGuard VPN

Published on November 09, 2020