How To Install Docker On Ubuntu 18.04

Stella981
• 阅读 678

Docker is an increasingly popular software package that creates a container for application development.

Developing in Docker speeds up applications, as it shares the kernel and other resources, instead of requiring dedicated resources.

There are two versions of Docker – Docker CE (Community Edition) and Docker EE (Enterprise Edition). If you have a small-scale project, or you’re just learning, you’ll want to use Docker CE.

In this tutorial, we will cover how to install Docker on Ubuntu 18.04.

How To Install Docker On Ubuntu 18.04

Prerequisites

  • Ubuntu 18.04 64-bit operating system
  • A user account with sudo privileges
  • Command line / terminal (CTRL-ALT-T or Applications menu > Accessories > Terminal)
  • Docker software repositories (optional)

Install Docker on Ubuntu Using Default Repositories

Step 1: Update Software Repositories

As usual, it’s a good idea to update the local database of software to make sure you’ve got access to the latest revisions.

Therefore, open a terminal window and type:

sudo apt-get update

Allow the operation to complete.

Step 2: Uninstall Old Versions of Docker

Next, it’s recommended to uninstall any old Docker software before proceeding.

Use the command:

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

Step 3: Install Docker

To install Docker on Ubuntu, in the terminal window enter the command:

sudo apt install docker.io

Step 4: Start and Automate Docker

The Docker service needs to be setup to run at startup. To do so, type in each command followed by enter:

sudo systemctl start docker

sudo systemctl enable docker

How To Install Docker On Ubuntu 18.04

Step 5 (Optional): Check Docker Version

To verify the installed Docker version number, enter:

docker --version

How To Install Docker On Ubuntu 18.04


Note: The official Docker website does not offer support for Ubuntu 18.04. It’s possible that the Ubuntu default repositories have not updated to the latest revision. There’s nothing wrong with running this installation. However, if you are up for a slightly more intensive operation, you can install a more recent (or specific) Docker from the official Docker repositories.


How To Install Docker On Ubuntu 18.04

Alternative: Install Docker from Official Repository

Step 1: Update Local Database

Update the local database with the command:

sudo apt-get update

Step 2: Download Dependencies

You’ll need to run these commands to allow your operating system to access the Docker repositories over HTTPS.

In the terminal window, type:

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

To clarify, here’s a brief breakdown of each command:

  • apt-transport-https: Allows the package manager to transfer files and data over https
  • ca-certificates: Allows the system (and web browser) to check security certificates
  • curl: This is a tool for transferring data
  • software-properties-common: Adds scripts for managing software

Step 3: Add Docker’s GPG Key

The GPG key is a security feature.

To ensure that the software you’re installing is authentic enter:

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

How To Install Docker On Ubuntu 18.04

Step 4: Install the Docker Repository

To install the Docker repository, enter the command:

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

The command “$(lsb_release –cs)” scans and returns the codename of your Ubuntu installation – in this case, Bionic. Also, the final word of the command – stable– is the type of Docker release.

How To Install Docker On Ubuntu 18.04

A stable release is tested and confirmed to work, but updates are released less frequently. You may substitute edge if you’d like more frequent updates, at the cost of potential instability. There are other repositories, but they are riskier – more info can be found on the Docker web page.

Step 5: Update Repositories

Update the repositories you just added:

sudo apt-get update

Step 6: Install Latest Version of Docker

To install the latest version of docker:

sudo apt-get install docker-ce

Step 7 (Optional): Install Specific Version of Docker

List the available versions of Docker by entering the following in a terminal window:

apt-cache madison docker-ce

How To Install Docker On Ubuntu 18.04
The system should return a list of available versions as in the image above.

At this point, type the command:

sudo apt-get install docker-ce=<VERSION>

However, substitute for the version you want to install (pulled from the list you just generated).

For example:

How To Install Docker On Ubuntu 18.04

Step 8 (Optional): Install from a .deb Package

First, open a web browser, and go to the following web address:

https://download.docker.com/linux/ubuntu/dists/bionic/

Next, click on the pool link, then stable, then amd64.  This is the location of the stable Docker releases for Ubuntu 18.04.

How To Install Docker On Ubuntu 18.04

At the time this article was written, this directory was empty. This indicates that there are no verified stable releases for Ubuntu 18.04.

Not to worry, though! The previous versions should work just fine. Alternatively, you can install an edge release by browsing to:

https://download.docker.com/linux/ubuntu/dists/bionic/pool/edge/amd64/

Download the file, and make a note of the path where you saved it. Use the following command:

sudo dpkg -i /path/to/package.deb

Substitute your file location for /path/to/package.deb. Allow the installer to run.

Conclusion

Great job!  You’ve got three (3) different options for installing Docker on Ubuntu 18.04.

Finally, you can check the Docker guides if you get into trouble, plus they have a fairly robust forum you can search. Happy developing!

Next, You Should Also Read:

Author


How To Install Docker On Ubuntu 18.04

Sofija Simic

Sofija Simic is an aspiring Technical Writer at phoenixNAP. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
Opencv中Mat矩阵相乘——点乘、dot、mul运算详解
Opencv中Mat矩阵相乘——点乘、dot、mul运算详解2016年09月02日00:00:36 \牧野(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fme.csdn.net%2Fdcrmg) 阅读数:59593
Stella981 Stella981
3年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
10个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这