How to install Docker on Ubuntu

本文详细介绍了如何在Ubuntu 16.04上安装Docker,包括更新包列表,安装必要的依赖软件,添加Docker官方仓库,安装Docker引擎,并通过运行hello-world镜像验证安装是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Docker currently only runs on 64-bits platforms and requires that the kernal version be no less than 3.10.
in this tutorial , i use ubuntu 16.04 and the kernal version is 4.13.0-43-generic
you can use this command to find your linux-version and linux-kernal version.

uname -a 
cat /proc/version

At the first , you need to update your existing list of packages:

sudo apt update

Second, you need to install a few prerequisite packages which let apt use packages over HTTPS

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

add the GPG key for the official Docker repository to your system:

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

Add the Docker repository to APT sources:

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

update the package database with the Docker packages from the newly added repo:

sudo apt-get update

After you can install Docker

sudo  apt-get install docker-ce

if you have error on apt-get like this :
How to install Docker on Ubuntu
you can use this command to find the process using apt , and kill it !

ps aux | grep apt

How to install Docker on Ubuntu
after that , how can you check that docker is installed ?
you can use this command to chek

sudo service docker start 
docker version

How to install Docker on Ubuntu

Than,test that your installation works by running the simple Docker image, hello-world:

root@ubuntu:~# docker run hello-world

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/get-started/

List the hello-world container (spawned by the image) which exits after displaying its message. If it were still running, you would not need the --all option:

root@ubuntu:~# docker container ls --all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
46ea9cb299d4        hello-world         "/hello"            2 minutes ago       Exited (0) 2 minutes ago                        objective_mestorf
1d9c5cbbed49        hello-world         "/hello"            9 minutes ago       Exited (0) 9 minutes ago                        goofy_diffie
fef4ade3de12        hello-world         "/hello"            22 minutes ago      Exited (0) 22 minutes ago                       pensive_brown
6d77512305e5        hello-world         "/hello"            22 minutes ago      Exited (0) 22 minutes ago                       vigorous_heyrovsky

Reference:
https://askubuntu.com/questions/15433/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process

转载于:https://blog.51cto.com/12098022/2294095

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值