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:/#

No comments:

Post a Comment