Tuesday, February 21, 2017

Admiral - Management UI for Containers (Docker)

VMware Admiral is a highly scalable and very lightweight Container Management platform for deploying and managing container based applications. It is designed to have a small footprint and boot extremely quickly. Admiral is intended to provide automated deployment and lifecycle management of containers.

  • Rule-based resource management - Setup your deployment preferences to let Admiral manage container placement.
  • Live state updates - Provides a live view of your system.
  • Efficient multi-container template management - Enables logical multi-container application deployments.


Installation & Configuration


It can be run as a container(pretty simple isn’t it ). Run following command

docker run -d -p 8282:8282 --name admiral vmware/admiral


You can make sure if Admiral container is running using following command

docker ps | grep admiral


Open http://:8282 in browser


Click on Add a Host
Before you add host please ensure Remote API is enabled for the host. Please refer my previous blog  - http://bit.ly/2kRQqOc


Fill in details and add the host

Address – http://:2375
Placement Zone – Choose default-placementzone
Login Credentials – you will need to create new and choose that



Now you can manage containers or create new if required.  Following the Admiral Container which we created


 For more information refer official Github link - Click Here 

Enabling Docker Remote API on Ubuntu 16.04

After I wrote my previous blog, I realized it will be good idea to write instruction to enable Remote API

Following instructions were prepared for Ubuntu 16.04
  • Find out where the docker. service file is located:
  • systemctl show --property=FragmentPath docker
  • Display docker.service configuration using following command.
  • cat /lib/systemd/system/docker.service
  •  Please note we will be modifying ExecStart Variable
  •  
  •  Modify the ExecStart variable using following procedure
  •  Open docker.service file using following command
  •  sudo vim /lib/systemd/system/docker.service
  •  Press Alt I to insert the text.
  • Navigate to the row for ExecStart and add following
  •  ExecStart=/usr/bin/dockerd -H 0.0.0.0:2375 -H fd://
  •  To save Press Esc + wq!
  •  Verify configuration using following command
  •  cat /lib/systemd/system/docker.service
  •  
  •  Now update SystemD and restart Docker by running following 2 commands
  • sudo systemctl daemon-reload
  • sudo systemctl restart docker
  • Verify docker is listening on any IP and the port specified
  • systemctl status docker
  •  Now you should be able to access Docker API remotely i.e. You should be able to add host in Management UI (Portainer – Please refer my previous blog)
  •  
  • Once Host is Added you can view it under Dashboard
  •  




Saturday, February 11, 2017

Portainer - Management UI for Docker

Introduction


Portainer is an Open Source Management UI which gives you access to a central overview of your Docker host or Swarm cluster. From the dashboard, you can easily access any manageable entity.

It includes following sections

  • Container List  - The containers section provides a view of all available containers. You can see details about the containers (state, image, exposed ports...), filter or sort the containers and manage them using standard actions (start, run, remove...)
  • Image Details  - Access a lot more information in the image details section from the size of the image to the related Dockerfile information
  • Networks - The networks section provides a view of all available networks. Easily manage your networks from a centralized view or quickly create new networks.
  • Volumes - As for the networks, you can easily manage the available volumes from this section and create more volumes


Installation


It runs as a container so it’s as simple as running single following command

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer


docker ps | grep portainer



Once you set the password you it will ask you to login


You can manage local as well as remote docker instances from single portainer setup. I am demonstrating my local instance


Once you click Connect – Wallah it displays the Dashboard
It displays following information

  • Name
  • Docker Version
  • CPU
  • Memory
  • Containers
  • Images
  • Volumes



Add a New Endpoint


Navigate to End Points under Portainer Settings on bottom left hand screen



Please refer following link for more details



Thursday, February 9, 2017

Wednesday, February 8, 2017

Basic Docker CLI Commands

Once you have install docker logical next step is to playaround with basic commands to ensure you get comfortable .  If you haven’t had chance then you can refer my previous post of Docker Installation (Click Here)

Full set of commands along with description can be found on
  

I thought of sharing the basic commands which could be useful for the guys who are doing it for the first time
Category
Command
Description
Output
Containers
docker run “image name”
creates and starts a container in one operation
Containers
docker run -it ubuntu /bin/bash
launch a bash shell interactively in the new Ubuntu container

Note

Notice the prompt has change from host to container
Containers
docker run -d ubuntu /bin/sh -c "while true; do echo 'hello docker'; sleep 10; done"
You can run containers in the
background as daemons with the docker run -d switch
Containers
docker ps
docker ps –a

With recent release of docker we can also use

docker container ls
docker container ls –a
List Active containers.
If used –a it lists all containers
Containers
docker exec -it “containerid” “cmd”
Run a command in a running container
Containers
docker rm “Container ID ”
Remove one or more containers
Images
docker images
List images
Images
docker rmi “Image ID”
Remove one or more images
Debugging/Troubleshooting

docker log “containerid’
Fetch the logs of a container
Debugging/Troubleshooting

docker stats -a
Display a live stream of container(s) resource usage statistics
Debugging/Troubleshooting
docker top “containerid”
Display the running processes of a container
Debugging/Troubleshooting
docker inspect “containerid”
Return low-level information on Docker objects.
In my example I have searched for IP Address of the container using grep

Tuesday, February 7, 2017

Docker Installation on Ubuntu 16.04

Introduction


Docker is a tool that automates the deployment of applications inside software containers ( Container is an operating-system-level virtualization method for running application as single processes)

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment

OS requirements


I will be installing docker on Ubuntu and to install Docker, you need the 64-bit version of Ubuntu. You can check current version on Ubuntu using following command.

root@MunishLabUbuntu:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

As per Docker documentation. You could use any of these versions
  • Yakkety 16.10
  • Xenial 16.04 (LTS)
  • Trusty 14.04 (LTS)

Docker Installation


You can install Docker in different ways, depending on your needs:

  • Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach. This would require access to Internet from the Host
  • Some users download the DEB package and install it manually and manage upgrades completely manually.
  • Go to https://apt.dockerproject.org/repo/pool/main/d/docker-engine/ and download the .deb file for the Docker version you want to install and for your version of Ubuntu
  • Some users cannot use the official Docker repositories, and must rely on the version of Docker that comes with their operating system. This version of Docker may be out of date. Those users should consult their operating system documentation and not follow these procedures.

 Install using the repository

 Before you install Docker for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install, update, or downgrade Docker from the repository

Set up the repository


You could setup repository in 2 ways


Installation Procedure


I will be using Get Docker Script to perform the installation. # This script is meant for quick & easy install via:

curl -sSL https://get.docker.com/ | sh
or
wget -qO- https://get.docker.com/ | sh

Manage Docker as a non-root user


The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user. If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group with something like:

sudo usermod -aG docker user

Remember that you will have to log out and back in for this to take effect!

Verify Installation


docker --version

root@MunishLabUbuntu:/# docker --version
Docker version 1.13.0, build 49bf474
root@MunishLabUbuntu:/#

docker version

root@MunishLabUbuntu:/# docker version
Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:58:26 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:58:26 2017
 OS/Arch:      linux/amd64
 Experimental: false
root@MunishLabUbuntu:/#

systemctl status docker

root@MunishLabUbuntu:/# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2017-02-06 17:25:16 PST; 1h 47min ago
     Docs: https://docs.docker.com
 Main PID: 6924 (dockerd)
    Tasks: 24
   Memory: 29.7M
      CPU: 18.085s
   CGroup: /system.slice/docker.service
           ├─6924 /usr/bin/dockerd -H fd://
           └─6933 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/l

Feb 06 17:25:16 MunishLabUbuntu dockerd[6924]: time="2017-02-06T17:25:16.000065756-08:00" level=info msg="Loading containers: done."
Feb 06 17:25:16 MunishLabUbuntu dockerd[6924]: time="2017-02-06T17:25:16.034008639-08:00" level=info msg="Daemon has completed initialization"
Feb 06 17:25:16 MunishLabUbuntu dockerd[6924]: time="2017-02-06T17:25:16.034063872-08:00" level=info msg="Docker daemon" commit=49bf474 graphdriver=aufs version=1.13.0
Feb 06 17:25:16 MunishLabUbuntu systemd[1]: Started Docker Application Container Engine.
Feb 06 17:25:16 MunishLabUbuntu dockerd[6924]: time="2017-02-06T17:25:16.053682875-08:00" level=info msg="API listen on /var/run/docker.sock"
Feb 06 18:55:38 MunishLabUbuntu dockerd[6924]: time="2017-02-06T18:55:38.147230105-08:00" level=error msg="Handler for POST /v1.25/containers/create returned error: No
Feb 06 18:55:40 MunishLabUbuntu dockerd[6924]: time="2017-02-06T18:55:40.757294002-08:00" level=warning msg="Your kernel does not support swap memory limit."
Feb 06 18:55:40 MunishLabUbuntu dockerd[6924]: time="2017-02-06T18:55:40.757395172-08:00" level=warning msg="Your kernel does not support cgroup rt period"
Feb 06 18:55:40 MunishLabUbuntu dockerd[6924]: time="2017-02-06T18:55:40.757428312-08:00" level=warning msg="Your kernel does not support cgroup rt runtime"
Feb 06 18:55:41 MunishLabUbuntu dockerd[6924]: time="2017-02-06T18:55:41.058648777-08:00" level=error msg="containerd: deleting container" error="exit status 1: \"conta

root@MunishLabUbuntu:/#


docker info

root@MunishLabUbuntu:/# docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 1
Server Version: 1.13.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 3
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-31-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.842 GiB
Name: MunishLabUbuntu
ID: ZPWT:PVIT:VMHY:QTAH:6PDZ:4MO6:SSSE:3P5B:GR5X:BVBB:ZQ4A:IZWB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
root@MunishLabUbuntu:/#


docker run hello-world


root@MunishLabUbuntu:/# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
root@MunishLabUbuntu:/#