Getting started with Docker: Installation, first steps

By: (plus.google.com) +David Herron; Date: April 5, 2018

Tags: Docker » Docker MAMP

Let's start this journey into Docker by learning how to install it on popular systems. Installation is a lot simpler today than at the beginning, especially on Mac and Windows. You youngsters don't know how easy you have it now that Docker for Mac and Docker for Windows exist. In the old days we had to walk 10 miles through the snow, uphill both ways, to install VirtualBox along with a specialized virtual machine to use Docker.

macOS installation

Official instructions: (docs.docker.com) https://docs.docker.com/docker-for-mac/install/

Simple - you download the Docker for Mac bundle, which is named Docker.dmg. As the name implies this is a disk image, which you double-click to open. Once opened, you drag the Docker icon to the Applications folder.

Once copied to the Applications folder, you double click the Docker icon to launch the application.

It starts like a regular Mac application, and in all ways behaves like one.

An icon is added to the top status bar. The icon shows current status, and gives access to a menu showing further details, and allowing you to start Kitematic and perform some other diagnostic rituals.

Docker for Mac relies on an extremely light-weight hypervisor, HyperKit. Inside that hypervisor is running a Linux system with enough capability to host Docker services. Processes associated with your Docker containers are not running in macOS, but instead are running in this Linux image inside the hypervisor.

Mac hardware must be a 2010 or newer model. The OS must be macOS El Capitan 10.11 or newer. If VirtualBox is installed, it must be newer than version 4.3.30.

Windows installation

Official instructions: (docs.docker.com) https://docs.docker.com/docker-for-windows/install/

Once you've downloaded the installer, Docker for Windows Installer.exe, run it to go through the install wizard.

Once Docker is installed, it is launched through the Start menu, just like any Windows application. From here it behaves like a Windows app, for example an icon is added to the taskbar.

Docker for Windows relies on an extremely light-weight hypervisor, Hyper-V. Hunt around Windows and you'll find some applications for inspecting Hyper-V based VM's, one of which will be your Docker VM. Like for Docker for Mac, the Docker containers you run on Windows will not be Windows processes, but instead will run in the Linux image running inside the Hyper-V hypervisor.

Virtualization must be enabled which may mean a trip to your BIOS or UEFI or whatever it is you use to configure the hardware before booting the computer.

Linux installation

Official Ubuntu instructions: (docs.docker.com) https://docs.docker.com/install/linux/docker-ce/ubuntu/

Official Debian instructions: (docs.docker.com) https://docs.docker.com/install/linux/docker-ce/debian/

Official CentOS instructions: (docs.docker.com) https://docs.docker.com/install/linux/docker-ce/centos/

Official Fedora instructions: (docs.docker.com) https://docs.docker.com/install/linux/docker-ce/fedora/

Docker runs natively on Linux and therefore does not require a hypervisor. Installation is done through the official package management system for the above distros. On other distros you have a couple hoops to jump.

You may need to remove old versions first:

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

Then:

$ sudo apt-get update
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce

Details are on the official instructions page. That may look like a lot of steps, but it's fairly straight-forward. The first few lines add the Docker repository to your sources, and the last one installs Docker CE.

Post-install instruction for Linux

All versions of Linux have some post-install steps to make it more convenient to use Docker.

See: (docs.docker.com) https://docs.docker.com/install/linux/linux-postinstall/

$ sudo groupadd docker
$ sudo usermod -aG docker $USER

This adds a new group named docker. Any user in the docker group can run the Docker commands, meaning they do not have to use sudo docker but just docker. Repeat the usermod command for each user ID that is to have access to the docker command.

# for systemctl
$ sudo systemctl enable docker
# for upstart
$ echo manual | sudo tee /etc/init/docker.override
# for chkconfig
$ sudo chkconfig docker on

The next step is configuring Docker to launch when the system reboots. That means any restart: always Docker container can be used as a background daemon service.

Those are the most important things to do. You can also configure storage drivers and many other settings.

Tire Kicking

david@nuc2:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete 
Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
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.
    (amd64)
 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/

The hello-world container is used as a demonstration of some basic Docker usage. This demonstrates how Docker automatically downloads any container image it doesn't have locally, and then the image is instantiated into a Container before execution.

By default the docker run command runs the container in the foreground, meaning that the standard-output of the launched command prints on the users terminal.

In this case it's a simple command to print a useful message describing some further steps you can take with Docker.

david@nuc2:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                                                                NAMES
b94b72b0bbab        hello-world         "/hello"                 3 minutes ago       Exited (0) 3 minutes ago                                                                        priceless_kilby
c2c9253b571b        nextcloud           "/entrypoint.sh apac…"   24 hours ago        Up 24 hours                80/tcp                                                               nextcloud
7bf3ee9bddd9        nginx_nginx         "sh -c 'nginx && cro…"   25 hours ago        Up 25 hours                0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp                             nginx
0152a5a7dc46        gogs/gogs           "/app/gogs/docker/st…"   4 days ago          Up 4 days                  22/tcp, 0.0.0.0:3080->3080/tcp, 3000/tcp, 0.0.0.0:10022->10022/tcp   gogs

This shows the Docker containers running on the system. I have a few executing full-time on this server. The hello-world container is listed here with the name priceless_kilby.

If a Docker container is executed without specifying a name, Docker will concoct a name. In this case priceless_kilby was what was chosen.

david@nuc2:~$ docker rm priceless_kilby
priceless_kilby

Didn't your mother teach you to clean up after yourself? Mine did. Not that I paid attention, but she did teach me this. Eventually I listened.

« A DIY iPhone storage upgrade - the upgrade Apple hates the most Facebook is selling user data, even as Facebook does not sell user data »
refurb.io
2016 Election Acer C720 Ad block AkashaCMS Amazon Amazon Kindle America Amiga Android Anti-Fascism AntiVirus Software Apple Apple Hardware History Apple iPhone Apple iPhone Hardware April 1st Arduino ARM Compilation Astronomy Asynchronous Programming Authoritarianism Automated Social Posting Ayo.JS Bells Law Big Brother Big Finish Bitcoin Mining Black Holes Blade Runner Blockchain Blogger Blogging Books Botnet Botnets Cassette Tapes Cellphones Christopher Eccleston Chrome Chrome Apps Chromebook Chromebooks Chromebox ChromeOS CIA CitiCards Citizen Journalism Civil Liberties Clinton Cluster Computing Command Line Tools Comment Systems Computer Hardware Computer Repair Computers Cross Compilation Crouton Cryptocurrency Curiosity Rover Currencies Cyber Security Cybermen Daleks Darth Vader Data backup Data Storage Database Database Backup Databases David Tenant DDoS Botnet Detect Adblocker Developers Editors Digital Photography Diskless Booting Disqus DIY DIY Repair DNP3 Do it yourself Docker Docker MAMP Docker Swarm Doctor Who Doctor Who Paradox Drobo Drupal Drupal Themes DVD E-Books E-Readers Early Computers Election Hacks Electric Bicycles Electric Vehicles Electron Emdebian Encabulators Energy Efficiency Enterprise Node EPUB ESP8266 Ethical Curation Eurovision Event Driven Asynchronous Express Facebook Fake News Fedora VirtualBox File transfer without iTunes FireFly Flickr Fraud Freedom of Speech Gallifrey git GitKraken Gitlab GMAIL Google Google Chrome Google Gnome Google+ Government Spying Great Britain Heat Loss Hibernate Hoax Science Home Automation HTTP Security HTTPS Human ID I2C Protocol Image Analysis Image Conversion Image Processing ImageMagick In-memory Computing InfluxDB Infrared Thermometers Insulation Internet Internet Advertising Internet Law Internet of Things Internet Policy Internet Privacy iOS Devices iPad iPhone iPhone hacking Iron Man Iternet of Things iTunes Java JavaScript JavaScript Injection JDBC John Simms Journalism Joyent Kaspersky Labs Kindle Kindle Marketplace Lets Encrypt LibreOffice Linux Linux Hints Linux Single Board Computers Logging Mac Mini Mac OS Mac OS X Machine Learning Machine Readable ID macOS MacOS X setup Make Money Online March For Our Lives MariaDB Mars Matt Lucas MEADS Anti-Missile Mercurial Michele Gomez Micro Apartments Military Hardware Minification Minimized CSS Minimized HTML Minimized JavaScript Missy Mobile Applications MODBUS Mondas Monetary System MongoDB Mongoose Monty Python MQTT Music Player Music Streaming MySQL NanoPi Nardole NASA Net Neutrality Node Web Development Node.js Node.js Database Node.js Testing Node.JS Web Development Node.x North Korea npm NVIDIA NY Times Online advertising Online Community Online Fraud Online Journalism Online Photography Online Video Open Media Vault Open Source Open Source Governance Open Source Licenses Open Source Software OpenAPI OpenVPN Paywalls Personal Flight Peter Capaldi Photography PHP Plex Plex Media Server Political Protest Postal Service Power Control Privacy Production use Public Violence Raspberry Pi Raspberry Pi 3 Raspberry Pi Zero Recycling Refurbished Computers Remote Desktop Republicans Retro Computing Retro-Technology Reviews Right to Repair River Song Robotics Rocket Ships RSS News Readers rsync Russia Russia Troll Factory Russian Hacking SCADA Scheme Science Fiction Search Engine Ranking Season 1 Season 10 Season 11 Security Security Cameras Server-side JavaScript Shell Scripts Silence Simsimi Skype SmugMug Social Media Social Media Warfare Social Networks Software Development Space Flight Space Ship Reuse Space Ships SpaceX Spear Phishing Spring Spring Boot SQLite3 SSD Drives SSD upgrade SSH SSH Key SSL Stand For Truth Swagger Synchronizing Files Telescopes Terrorism The Cybermen The Daleks The Master Time-Series Database Torchwood Total Information Awareness Trump Trump Administration Trump Campaign Ubuntu Udemy UDOO Virtual Private Networks VirtualBox VLC VNC VOIP Web Applications Web Developer Resources Web Development Web Development Tools Web Marketing Website Advertising Weeping Angels WhatsApp Window Insulation Windows Windows Alternatives Wordpress World Wide Web Yahoo YouTube YouTube Monetization