百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

Docker 实战2:Ubuntu 安装 Docker

nanshan 2024-11-04 13:05 27 浏览 0 评论

Docker 最初的版本就是运行在 Ubuntu 上,所以,Ubuntu 上安装 Docker 应该是最简单的了

系统要求

Docker CE 对 Ubuntu 的系统还是有一定的要求的

1、 首先必须是64位版本的,这个应该问题不大,只要不是老古董,早就是64位的了;
2、 Ubuntu的版本必须是下表,或者比下表更新的版本;

Artful 17.10 (Docker CE 17.11 Edge and higher only)
Xenial 16.04 (LTS)
Trusty 14.04 (LTS)

3、 Docker要求Ubuntu系统的内核版本高于3.10;

我们可以使用 uname -r 命令来查看当前的内核版本
[root@ddkk.com ~] uname -r 
4.2.0-16-generic

安装 Docker

Ubuntu 安装 Docker 的方式有很多中,我们选择最省事的那种,最快速的那种

目前最快速的安装 Docker 的方式是使用官方给出的脚本 https://get.docker.com/

只需要在终端里输入以下命令即可开始安装

[root@ddkk.com ~]# curl -fsSL get.docker.com -o get-docker.sh
[root@ddkk.com ~]# sudo sh get-docker.sh
...
...

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group grants the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

如果你使用的是 root 用户,可以先轻松下再回来,如果你使用的是普通用户,那么需要 sudo sh get-docker.sh,然后输入登录密码

稍等片刻,Docker 就会安装完毕,是不是很省事,因为我们连一张图都没发

可以安装完成后最后那几段提示

If you would like to use Docker as a non-root user, you should now consider
    adding your user to the "docker" group with something like:

    sudo usermod -aG docker your-user

   Remember that you will have to log out and back in for this to take effect!

意思是说,如果以非 root 用户可以运行 docker 时,需要执行 sudo usermod -aG docker souyunku 命令然后重新登陆,否则会有如下报错

[penglei@localhost ~]docker fun hello-world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host ?
...

启动 docker 服务

可以使用 services docker start 命令启动 Docker

[root@ddkk.com ~]# service docker start

Docker Hello World

可以使用 docker run hello-world 命令运行 Hello World 查看是否安装成功

[root@ddkk.com ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete 
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

相关推荐

Centos7虚拟机安装及网络配置(二)

#二、centos7的网络配置-Nat模式NAT模式也是VMware创建虚拟机的默认网络连接模式。使用NAT模式网络连接时,VMware会在主机上建立单独的专用网络,用以在主机和虚拟机之间相互通信。虚...

网络分析shell脚本(实时流量+连接统计)

介绍一个强大的分析网络的shell脚本,此脚本是从EZHTTP拆分出来的,觉得有必要单独介绍下。脚本运行效果截图:此脚本包含的功能有:1、实时监控任意网卡的流量2、统计10秒内平均流量3、统计每个端口...

Centos之Could not retrieve mirrorlist解决方案

Centos之Couldnotretrievemirrorlist解决方案:vi/etc/sysconfig/network-scripts/ifcfg-你的网卡名字修改:ONBOOT=ye...

一文掌握!VirtualBox 中 Rock9.x(Linux)网络配置全攻略

一、前言记得我有一篇文章《必看!VirtualBox中Centos7(Linux)网络配置全攻略》讲的非常明细,但是因为CentOS已经停止维护了,可能很多人都不想继续学CentOS,我也是一样,...

CentOS 6.0 设置IP地址、网关、DNS

在做任何操作之前先备份原文件,我们约定备份文件的名称为:源文件名称+bak,例如原文件名称为:centos.txt那么备份文件名称为:centos.txtbak引言:linux的网卡IP地址是存放在文...

Linux CentOS 基础操作(centos怎么操作)

简介:养成学习Linux的好习惯,第一是多查看manpage(manual)等帮助文档和利用好Tab键;第二是掌握好一些快捷键,比如ctrl+c(停止当前进程),ctrl+r(查看命令历史)...

Linux抓包王者技能!这条命令直接封神,教你精准定位网络问题

在网络故障排查和性能调优中,抓包是一项必不可少的技能。对于Linux环境下的网络工程师和运维人员来说,掌握高效抓包方法至关重要。而要说“抓包界的王炸”,那非tcpdump莫属!今天,我们不仅要介绍...

「干货」如何在 Linux 上划分VLAN?

在某些场景中,我们希望在Linux服务器(CentOS/RHEL)上的同一网卡分配来自不同VLAN的多个ip。这可以通过启用VLAN标记接口来实现,但要实现这一点,首先必须确保交换机上添加多个vl...

CentOS 8 网络配置实战教程:静态IP、路由与DNS设置

一、配置前准备1.查看当前网络信息#查看所有网络接口nmclidevicestatus#查看指定网卡信息(假设网卡名为ens192)ipaddrshowens192#查看路由...

Debian10.7修改网络配置(debian怎么配置网络)

简介:关于Debian获取IP地址的方法主要有两种,动态获取和静态设置。在配置网络之前先要知道Debian的网卡名称是什么,Debian可通过命令#ipa查看网卡名称。本文主要通过介绍Debian...

巧用SSH转发功能深入穿透内网(ssh转发udp)

ssh能够提供客户端到服务端的加密传输,当http、ftp等协议被防火墙所拦截时,可以考虑使用SSH的端口转发功能,将其它TCP端口的网络数据通过SSH连接来转发。转发方式一共有三种,分别是:动态转发...

CentOS Linux 7 的IP地址配置(centos7.4配置ip地址)

前段时间有位朋友,在一台PC机上安装了CentOSLinux7系统,因为要接入局域网,需要配置IP地址和默认网关信息。于是参照一本Linux教程上编辑网卡配置信息的方法,输入:vim/etc/s...

教你如何在 Linux 上划分VLAN(linux怎么分区详解)

在某些场景中,我们希望在Linux服务器(CentOS/RHEL)上的同一网卡分配来自不同VLAN的多个ip。这可以通过启用VLAN标记接口来实现,但要实现这一点,首先必须确保交换机上添加多个vl...

打通数据高速公路:如何在 CentOS 上使用 Thunderbolt 3 和 4

Thunderbolt3与4是现代高速外设连接的代表,带来了40Gbps的惊人带宽,支持数据、视频、音频与供电的“四合一”功能,尤其在专业视频编辑、科研计算、虚拟化扩展等领域具有巨大价值...

VMware 虚拟机 CentOS7 桥接模式静态 IP 配置全攻略

虚拟机桥接模式原理配置成桥接网络连接模式的虚拟机就当作主机所在以太网的一部分,虚拟系统和宿主机器的关系,就像连接在同一个Hub上的两台电脑,可以像主机一样可以访问以太网中的所有共享资源和网络连接,可以...

取消回复欢迎 发表评论: