Docker for Beginners Part 2: Docker Installation on Mac and Ubuntu

DZone 's Guide to

Docker for Beginners Part 2: Docker Installation on Mac and Ubuntu

Here's the second installation of the beginner's Docker guide. Check out how to install Docker on a Mac or Ubuntu machine.

· Cloud Zone ·
Free Resource

This is the Part 2 from the Docker series, Docker for Beginners in 8 Parts. In this post we're going to see the an overview about the Docker installation.

  • Part 1 - Differences between Containers and Virtual Machines
  • Part 2 - Overview of Docker Installation for Mac and Ubuntu
  • Part 3 - Docker Images and Containers
  • Part 4 - Exploring Docker Images in Details
  • Part 5 - Exploring Docker Containers in Details
  • Part 6 - Building Custom Docker Images with Dockerfile
  • Part 7 - Pushing our Great Docker Image to Docker Hub
  • Part 8 - Keeping MongoDB Data with Docker Volumes

Docker is the new hype is not just hype anymore and you're probably already working with it, even without knowing it!

Docker brings to us the ability to create applications without worrying about its environment. Your production environment could be the same as the development environment. Yes, I know, I know, seems suspicious.

With Docker, we can create, for example, 3 isolated environments that can be executed in a single machine at the same time, simulating your production, development and stage environment. You'll see that this is pretty easy.

It's time to avoid that with Docker.

We're not going to see a detailed way to install Docker because this is really well covered by the official Docker documentation! Let's just see a fast overview of how to do it, straight to the point!

Installing Docker on Mac

Just install the Docker for Mac

Make the download in the Docker site and have fun with your .dmg and the drag and drop style.

A few words about Docker for Mac:

  • By default Mac does not have Docker without a Virtual Machine
  • A Virtual Machine with a minimal Linux distro will be installed
  • You can use the Stable or Edge version
  • You can configure Proxies and VPNs if you want

We're going to see a detailed post later about how Docker works in Mac.

Installing Docker on Ubuntu

To do that, we need to follow the steps below. Remember that the official site is really better than me and has a complete guide. Here we're going to see the installation from scratch but, again, straight to the point!

1. Let's update the apt package index!

sudo apt-get update

In this step we're just updating the apt package index to get new versions of packages, if there are any:

2 - Install packages to allow apt to use a repository over HTTPS.

This step is required because the apt-transport-https package enables us to use https:// to install a package. In our case, this is necessary to install Docker from the address with https.

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \

3 - Add Docker's official GPG key.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4 - Finding the last 8 characters of the fingerprint.

In this step we'll just test if we already have the key associated with the fingerprint. If everything is okay, you will see an output like this:

sudo apt-key fingerprint 0FEBEF45

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 7CC8 2133 5AC8 EE38 854A  E2D8 8D81 803C 0FEB EF45
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

5 - Use the following command to set up the stable repository.

You can use the stable, edge or test repositories but we always need to install the stable, even if you're planning to use just the edge repository:

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \

6 - Let's update the apt package index again:

sudo apt-get update

7 - Now we just need to install the Docker Community Edition

Docker has an Enterprise Version and the steps to install it differs from this.

sudo apt-get install docker-ce

That's it! Simple and fast!

Let's move on and see the next post: Part 3 - Docker Images and Containers

Follow us to keep up to date!

devops, docker, docker application, infrastructure

Published at DZone with permission of Alexandre Gama . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}