gb
  English
Phone:  +1 (217) 636-4164
Skype:  onegbits
  1. Home
  2. Blog
  3. How to install docker on Ubuntu 16.04

How to install docker on Ubuntu 16.04

How to install docker on Ubuntu 16.04

26

Sep, 16

84

How to install docker on Ubuntu 16.04

What is Docker?

Docker is an application that makes it simple and easy to run application processes in a container, which are like virtual machines, only more portable, more resource-friendly, and more dependent on the host operating system. For a detailed introduction to the different components of a Docker container, check out The Docker Ecosystem: An Introduction to Common Components. There are two methods for installing Docker on Ubuntu 16.04. One method involves installing it on an existing installation of the operating system. The other involves spinning up a dedicated server with a tool called Docker Machine that auto-installs Docker on it. In this tutorial, you'll learn how to install docker and use it on an existing installation of Ubuntu 16.04.

How to install docker

Before install Docker, it should required updated packages. To update the packages, use the following command
$ sudo apt-get update
Use the following command to add the GPG key for the official Docker repository to the system
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
The sample output should be like this
Executing: /tmp/tmp.akuLSrhQz8/gpg.1.sh --keyserver
hkp://p80.pool.sks-keyservers.net:80
--recv-keys
58118E89F3A912897C070ADBF76221572C52609D
gpg: requesting key 2C52609D from hkp server p80.pool.sks-keyservers.net
gpg: key 2C52609D: public key "Docker Release Tool (releasedocker) <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
To add the Docker repository to APT sources, use the following command
$ echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
To update the package database with the Docker packages from the newly added repository, use the following command
$ sudo apt-get update
Make sure you are about to install from the Docker repository instead of the default Ubuntu repository. To verify it, use the following command
$ apt-cache policy docker-engine
The sample output should be like this
docker-engine:
  Installed: (none)
  Candidate: 1.11.1-0~xenial
  Version table:
     1.11.1-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
     1.11.0-0~xenial 500
        500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages

Notice that, docker-engine is not installed,to install Docker-engine, use the following command
$ sudo apt-get install -y docker-engine
The sample output should be like this
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apport-hooks-elementary contractor libgda-5.0-4 libgda-5.0-common
  libgranite-common libgranite3 libgsignon-glib1 libindicate5 libnoise-core0
  libtagc0 mysql-server-5.7 mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  aufs-tools cgroupfs-mount
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount docker-engine
0 upgraded, 3 newly installed, 0 to remove and 212 not upgraded.
Need to get 14.6 MB of archives.
After this operation, 73.7 MB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB]
..............................................................................................
To check whether docker is started or not, use the following command
$ sudo systemctl status docker
The sample output should be like this
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
   Active: active (running) since Mon 2016-05-23 10:36:08 IST; 5min ago
     Docs: https://docs.docker.com
 Main PID: 14186 (docker)
    Tasks: 20 (limit: 512)
   Memory: 21.5M
      CPU: 385ms
   CGroup: /system.slice/docker.service
           ├─14186 /usr/bin/docker daemon -H fd://
           └─14204 docker-containerd -l /var/run/docker/libcontainerd/docker-con

May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.169666150+05:30" 
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.261017824+05:30" 
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.469630404+05:30" 
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.829495384+05:30" 
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.830931516+05:30" 
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.831009718+05:30" 
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.831055091+05:30" 
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.831113464+05:30" 
May 23 10:36:08 linux systemd[1]: Started Docker Application Container Engine.
May 23 10:36:08 linux docker[14186]: time="2016-05-23T10:36:08.855330148+05:30
To start the Docker service, use the following command
$ sudo service docker start
To view all the available subcommands of Docker, use the following command
$ docker
The sample output should be like this
Usage: docker [OPTIONS] COMMAND [arg...]
       docker daemon [ --help | ... ]
       docker [ --help | -v | --version ]

A self-sufficient runtime for containers.

Options:

  --config=~/.docker              Location of client config files
  -D, --debug                     Enable debug mode
  -H, --host=[]                   Daemon socket(s) to connect to
  -h, --help                      Print usage
  -l, --log-level=info            Set the logging level
  --tls                           Use TLS; implied by --tlsverify
  --tlscacert=~/.docker/ca.pem    Trust certs signed only by this CA
  --tlscert=~/.docker/cert.pem    Path to TLS certificate file
  --tlskey=~/.docker/key.pem      Path to TLS key file
  --tlsverify                     Use TLS and verify the remote
  -v, --version                   Print version information and quit

Commands:
    attach    Attach to a running container
    build     Build an image from a Dockerfile
    commit    Create a new image from a container's changes
    cp        Copy files/folders between a container and the local filesystem
    create    Create a new container
    diff      Inspect changes on a container's filesystem
    events    Get real time events from the server
    exec      Run a command in a running container
    export    Export a container's filesystem as a tar archive
    history   Show the history of an image
    images    List images
    import    Import the contents from a tarball to create a filesystem image
    info      Display system-wide information
    inspect   Return low-level information on a container or image
    kill      Kill a running container
    load      Load an image from a tar archive or STDIN
    login     Log in to a Docker registry
    logout    Log out from a Docker registry
    logs      Fetch the logs of a container
    network   Manage Docker networks
    pause     Pause all processes within a container
    port      List port mappings or a specific mapping for the CONTAINER
    ps        List containers
    pull      Pull an image or a repository from a registry
    push      Push an image or a repository to a registry
    rename    Rename a container
    restart   Restart a container
    rm        Remove one or more containers
    rmi       Remove one or more images
    run       Run a command in a new container
    save      Save one or more images to a tar archive
    search    Search the Docker Hub for images
    start     Start one or more stopped containers
    stats     Display a live stream of container(s) resource usage statistics
    stop      Stop a running container
    tag       Tag an image into a repository
    top       Display the running processes of a container
    unpause   Unpause all processes within a container
    update    Update configuration of one or more containers
    version   Show the Docker version information
    volume    Manage Docker volumes
    wait      Block until a container stops, then print its exit code

You can search for images available on Docker Hub by using the docker command with the search subcommand.
$ sudo docker search ubuntu
The sample output should be like this
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                            Ubuntu is a Debian-based Linux operating s...   3953      [OK]       
ubuntu-upstart                    Upstart is an event-based replacement for ...   62        [OK]       
rastasheep/ubuntu-sshd            Dockerized SSH service, built on top of of...   26                   [OK]
torusware/speedus-ubuntu          Always updated official Ubuntu docker imag...   26                   [OK]
ubuntu-debootstrap                debootstrap --variant=minbase --components...   24        [OK]       
nickistre/ubuntu-lamp             LAMP server on Ubuntu                           6                    [OK]
nickistre/ubuntu-lamp-wordpress   LAMP on Ubuntu with wp-cli installed            5                    [OK]
nuagebec/ubuntu                   Simple always updated Ubuntu docker images...   4                    [OK]
nimmis/ubuntu                     This is a docker images different LTS vers...   4                    [OK]
maxexcloo/ubuntu                  Docker base image built on Ubuntu with Sup...   2                    [OK]
partlab/ubuntu                    Simple Ubuntu docker images.                    1                    [OK]
darksheer/ubuntu                  Base Ubuntu Image -- Updated hourly             1                    [OK]
admiringworm/ubuntu               Base ubuntu images based on the official u...   1                    [OK]
jordi/ubuntu                      Ubuntu Base Image                               1                    [OK]
webhippie/ubuntu                  Docker images for ubuntu                        0                    [OK]
teamrock/ubuntu                   TeamRock's Ubuntu image configured with AW...   0                    [OK]
esycat/ubuntu                     Ubuntu LTS                                      0                    [OK]
life360/ubuntu                    Ubuntu is a Debian-based Linux operating s...   0                    [OK]
widerplan/ubuntu                  Our basic Ubuntu images.                        0                    [OK]
konstruktoid/ubuntu               Ubuntu base image                               0                    [OK]
lynxtp/ubuntu                     https://github.com/lynxtp/docker-ubuntu         0                    [OK]
datenbetrieb/ubuntu               custom flavor of the official ubuntu base ...   0                    [OK]
ustclug/ubuntu                    ubuntu image for docker with USTC mirror        0                    [OK]
uvatbc/ubuntu                     Ubuntu images with unprivileged user            0                    [OK]
rallias/ubuntu                    Ubuntu with the needful                         0                    [OK]

To see the images that have been downloaded to your computer, use the following command
$ sudo docker images
The sample output should be like this
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              94df4f0ce8a4        3 weeks ago         967 B
To run the Docker container, use the following command
$ sudo docker run -it hello-world
Above command runs hello-word container. the sample output should be like this
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 Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
To listing Docker Containers, use the following command
$ sudo docker ps
The sample output should be like this
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
f7c79cc556dd        ubuntu              "/bin/bash"         3 hours ago         Up 3 hours                              silly_spence
After this article, you will be able to understand – How To Install and Use Docker on Ubuntu 16.04 we will come up with more Linux based tricks and tips. Keep reading!
Save Save
Leave A Comment
We are with you

24 X 7 X 365

+1 (217) 636-4164

©2017 1Gbits. All rights reserved