Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Docker Cookbook

You're reading from   Docker Cookbook Over 100 practical and insightful recipes to build distributed applications with Docker

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher
ISBN-13 9781788626866
Length 352 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (3):
Arrow left icon
Neependra K Khare Neependra K Khare
Author Profile Icon Neependra K Khare
Neependra K Khare
Ken Cochrane Ken Cochrane
Author Profile Icon Ken Cochrane
Ken Cochrane
Jeeva S. Chelladhurai Jeeva S. Chelladhurai
Author Profile Icon Jeeva S. Chelladhurai
Jeeva S. Chelladhurai
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Introduction and Installation FREE CHAPTER 2. Working with Docker Containers 3. Working with Docker Images 4. Network and Data Management for Containers 5. Docker Use Cases 6. Docker APIs and SDKs 7. Docker Performance 8. Docker Orchestration and Hosting a Platform 9. Docker Security 10. Getting Help and Tips and Tricks 11. Docker on the Cloud 12. Other Books You May Enjoy

Installing Docker on Ubuntu

There are a few different versions of Ubuntu that are available. In this recipe, we will be installing Docker on Ubuntu 18.04, which is the latest LTS version as of writing. These same steps should also work with Ubuntu 16.04.

Getting ready

Check for the prerequisites mentioned in the previous recipe.

Uninstall any older versions of Docker. Previous versions of the Docker package are called docker, docker.io, or docker-engine. If these are installed, then we need to uninstall them, or else they might cause problems:

    $ sudo apt-get remove docker docker-engine docker.io

How to do it...

Go through the following steps:

  1. Update the apt package index:
   $ sudo apt-get update
  1. Install the packages to allow apt to use a repository over HTTPS:
       $ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
  1. Add Docker's official GPG key:
        $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK

Verify that we have the correct key installed:

        $ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
  1. Add the Docker apt repository using the stable channel:
       $ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
If you want more frequent updates, and you don't mind a few bugs, you can use the nightly test channel. To use the test channel, all you need to do is change stable to test in the preceding command.
  1. Update the apt package index so that it includes the Docker repository we just added:
       $ sudo apt-get update
  1. Install the latest version of Docker CE:
       $ sudo apt-get install docker-ce
  1. Verify that the installation worked:
       $ sudo docker container run hello-world

How it works...

The preceding command will install Docker on Ubuntu and all the packages required by it.

There's more...

The default Docker daemon configuration file is located at /etc/docker, which is used while starting the daemon. Here are some basic operations:

  • To start the service, enter the following:
    $ sudo systemctl start docker
  • To verify the installation, enter the following:
    $ docker info
  • To update the package, enter the following:
    $ sudo apt-get update
  • To enable the start of the service at boot time, enter the following:
    $ sudo systemctl enable docker
  • To stop the service, enter the following:
    $ sudo systemctl stop docker

See also

You have been reading a chapter from
Docker Cookbook - Second Edition
Published in: Aug 2018
Publisher:
ISBN-13: 9781788626866
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime