华强北电脑城 龙岗电子世界 龙华电脑城  凯尔电脑

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1409|回复: 2

Ubuntu 22.04安装Docker

[复制链接]
发表于 2022-5-21 19:17:06 | 显示全部楼层 |阅读模式
Docker是一个容器化平台,开发人员能够在容器内构建和部署应用。容器是隔离的环境,它将整个应用程序与其依赖项、库、配置文件以及使其运行所需的所有内容打包在一起,实现了跨平台。
步骤一、更新系统sudo apt update
9 W, C  u: ^9 x' |( D步骤二、安装依赖sudo apt install apt-transport-https curl gnupg-agent ca-certificates software-properties-common -y5 Z$ F* h9 r6 O5 \* c
步骤三、在Ubuntu 22.04安装Docker CE(社区版)
Docker CE是社区版,它是开源且免费的。
, j1 x( R, P$ F$ }+ Z" Y
增加GPG密钥curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -增加docker官方储存库 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"- u8 W- N) L' x8 q; _8 b/ |
安装docker cesudo apt install docker-ce docker-ce-cli containerd.io -y
3 L* X% q) ?$ I; _* @9 ~  L2 ]0 D步骤四、确认是否安装成功docker version管理Docker服务
启动docker
sudo systemctl start docker
重启docker
4 Q' p* ^8 H# @) @3 Z
sudo systemctl restart docker
停止docker
. f% J  G: \1 t0 W# S
sudo systemctl stop docker
让docker开机启动: {0 x8 W" S: Y: S; Y
sudo systemctl enable docker
禁用docker开机启动
6 L% Q' g) I) S* i1 F& g1 J9 t
sudo systemctl disable docker标签 : docker docker ce ubuntu7 J( t& Z1 v. e* Z

7 p% ~$ z. Y7 a3 t8 O
$ Y# }' c5 z* x- M# N) i. e( ]. r

; C% [& Q- x: oUbuntu 22.04安装Docker-ubuntu 22系统教程-热主机 (rezhuji.com)9 |8 d2 {! b/ |: F5 O
( s" q# A9 d! d8 u9 k6 l

2 k) Y& [8 l+ P( C如果您正在寻找一个开源且易于使用的Docker图形化管理。Portainer是一个很好的选择。
0 F* V( r6 p  L4 A, i
' t, d# j" x# R5 n" TPortainer Community Edition 是一个完全免费、功能强大的开源管理工具集,可让您轻松构建、管理和维护 Docker 环境。它支持 Windows、Linux 和 Mac OS。1 n5 v( s( `+ p4 b9 R( P' u& C
  l/ P; v5 ]  i3 b6 B
这个视频讲的是如何在一台VPS上安装Portainer,让我们通过浏览器,以图形化界面管理docker容器,并且用Nginx Proxy Manager来给portainer添加SSL安全证书。6 ^( w/ `! o* X9 h
  w7 F3 r# a6 O8 X( B0 G+ j

  G9 n) B7 p8 J; h+ k/ c
6 X, {4 J  a& Z
7 d  O& h& k9 n1. 安装DOCKER
5 q0 e: M9 |! L: \) B! `; W. J2 _! Q: p' Q* F# g/ M$ z2 ~# p. \7 a
sudo apt update4 h. A1 h, ?+ I

5 A$ z0 t' o: z8 Y& M. hsudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
( t$ n( a3 t6 j/ M& E) g0 g' @! |% O* r
curl -fsSL https://download.docker.com/linux/ubu... | sudo apt-key add -
5 [2 w$ N: O  o) G- M* H, |$ q( l9 v4 P& Z
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable": _* f% y6 C: c- S

9 z* z- _5 A5 \sudo apt update5 I5 V% b; D) @/ i- j

: F  {8 F) g( rsudo apt-get install docker-ce docker-ce-cli containerd.io: V3 w" B  X+ c$ `; I$ C& p0 m

3 j* C5 v5 x( q3 zdocker --version% p. S8 O9 a! ^) b
0 U5 t2 s1 V+ f6 p" ?3 }& _2 |
8 ]3 ?/ ?1 A; w4 l
2. 安装Docker-Compose
2 }$ c6 K" R8 V3 W8 O/ [$ J. j1 _8 ~% n, ~2 z6 r# P* J& m
sudo curl -L "https://github.com/docker/compose/rel... -s https://api.github.com/repos/docker/c... | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\1/')/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
6 A# S7 Q1 `& I8 M5 k, T' X' X3 N# W5 W; e. _; q3 U" r  h* {$ b
sudo chmod +x /usr/local/bin/docker-compose
1 E9 J) F5 M* H" {$ }% J6 @- S/ ], {( z- D3 Q: ~9 N$ p) s0 q
docker-compose --version
( s# [- e) t, L+ k! k& H
( f1 u$ u# Q0 `1 z3 `( n6 y6 s3. 设置Portainer   web管理Docker8 Z# E$ r7 d* c1 n7 n
---建立一个Docker卷
; h5 u" g' R. y1 M% L; fdocker volume create portainer_data" `, t2 ]  s8 c* r, d9 j

4 ^" z5 L% v( c2 g1 d---启用Portainer
9 K9 F; \* g! V: q& T: ]6 D1 }docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
' B8 F' W( i$ \; c! d5 M
: S% s, O8 ?- k6 z  e2 n
回复

使用道具 举报

 楼主| 发表于 2023-6-20 12:02:05 | 显示全部楼层
Hi there,$ ?! l" Q, \/ T2 Z3 i1 ?
  L- ?* I2 @% D3 O% [
In addition to what has already been mentioned, alternatively, you could use the Docker convenience installation script by running the following:+ Z) p5 q4 M9 ^. X3 V, Y

' O; q; A; j! \4 ?Download the script:
' ^+ b- P- y3 @2 u2 A3 y3 ycurl -fsSL https://get.docker.com -o get-docker.sh
( N2 b% ]% j/ k) fRun the script:
2 A2 p: }" U: I0 `6 X& bsudo sh get-docker.sh
) N3 k; m' D. E6 [Hope that this helps.
# _) b- z" a6 S7 U, S
, B: k1 [- G) N: p  mBest,
+ f' S1 ?. \2 U5 D
1 ]3 L; V4 z! u4 b! E/ @( PBobby
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-6-20 14:19:38 | 显示全部楼层
# **如何在 Ubuntu 22.04 上安装Docker和Docker Compose | VPS | Cloud Web Server**$ f' m$ v- L7 h4 E! w
3 O7 ?7 y9 ?, R
如何在 Ubuntu 22.04 上安装Docker和Docker Compose | VPS | Cloud Web Server (notion.site)
+ `! m; X$ L' Z+ j. ^
3 o& v, o% z' x2 X- e0 B9 I5 @Docker 是一个软件平台,用于开发基于容器(轻量级执行环境)的应用程序,这些应用程序具有独立共享操作系统内核的能力。
! c0 J: z- o4 x9 _
3 @/ y, z( o$ k! O6 [- EDocker Compose 是一个实用程序,它允许您基于 YAML 定义运行多容器应用程序设置。 它使用多个容器创建完全定制的环境,这些容器能够使用服务定义共享数据量和网络。% R( r4 ]% L/ w! `! n7 u/ ~1 c
3 g+ [2 l- ]$ J8 f+ S
这个视频将演示在 Ubuntu 22.04 上安装Docker和Docker Compose 的方法。* _; O9 t! {8 p8 b( V
0 y+ ?  Q! J/ [& g# O/ i
文字链接:
3 W2 y7 ^. [, |
! d( t( V5 J+ b[https://updayday.notion.site/Ubu ... 039bc72024395c58547](https://www.notion.so/Ubuntu-22- ... 024395c58547?pvs=21)
; m7 s: E7 q1 H6 \
7 K4 a! F: c0 P: L0 x1 d+ w& r& G& sDocker官网:+ X; c' u, V! e( U) f  I0 B- W
3 \& q3 s. q; G  W) t' s
https://docs.docker.com/engine/install/ubuntu/
6 l' N- V, ]0 G, W  T/ V) S+ L. a
Music from Uppbeat (free for Creators!):
3 H/ y7 o  D6 ~* Mhttps://uppbeat.io/t/soundroll/colors
0 {& t/ B( m& n+ q' zLicense code: ZHLPCR8LFXNWDKY5
: f* ]( H9 ?0 n9 K+ ~3 r: n* @4 E) z6 P  H$ M
[Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)
. T/ t& a2 j: n. e
& n/ y5 t" |1 E/ q- _8 {```bash
7 s2 Z9 G; s5 Z+ W+ i1 R" G3 a# 卸载旧版本) H: m% g+ i& a5 n& @; N! J6 Q/ d+ w
sudo apt-get remove docker docker-engine docker.io containerd runc- b+ O% ]/ m! G& v

: V" n! p- d: R. w# 设置 Docker 的存储库并从中安装,以便于安装和升级任务。这是推荐的方法。+ X1 u* x% ]' X
# 设置存储库
. V" M% \( Z# [: B# 1.更新apt包索引并安装包以允许apt通过 HTTPS 使用存储库:0 q0 O% z4 C8 x- w
sudo apt-get update8 C- B% u9 p6 v# I+ G6 Y
4 r/ v: [$ D6 Q5 c6 E. O
sudo apt-get install \
- ]0 a4 w2 b3 i: b3 h! z8 N    ca-certificates \/ S, D! J5 m1 ?  ^: L
    curl \& \3 l' n8 [- }. a! j
    gnupg \2 V* `4 h6 ?+ M( L7 |
    lsb-release
9 q/ g, ?' n' y! }$ O4 I7 ?$ M% N/ O1 a0 o
# 2.添加 Docker 的官方 GPG 密钥:
* n6 P$ Y- C$ M; wsudo mkdir -p /etc/apt/keyrings
, M* C5 z9 e$ k8 n9 W
3 Q( s% c: I, bcurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg1 _- C  `6 @+ n. z+ ?
! l; F! Y* ?$ e0 p: d6 I
# 3. 使用以下命令设置存储库:4 j* p0 @  T1 j, i" O' M  B/ R) p1 C' Y
echo \
: ]- N% q& x5 C, S; z8 {  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
' W9 F1 q9 z! n: u; ^& E% ~" S5 e  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null. E$ U! y) H3 t% }' }+ T, D
```
# ~  A1 C9 i. G! J8 m) _! }' \& Z" d- F: ~' v5 g
```bash+ _6 _5 }6 {% n. g
# 安装 Docker 引擎* r4 S; T4 C0 ]  x$ R. M% d
# 更新apt包索引,安装最新版本的 Docker Engine、containerd 和 Docker Compose
1 t( m: I5 R8 j% G, F6 E3 Nsudo apt-get update
0 N& ~5 e, \5 g9 ]
+ W9 U9 L* W- ?7 b) {$ U% u. `; l# nsudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin5 m+ ]0 S/ p, j; u5 T! @
+ i  W$ c2 @8 l' P7 \% {% m
# 运行时收到 GPG 错误apt-get update?
! k3 j3 f: C1 ~9 |  @8 P/ U! Q! z/ f" g- W
# 您的默认 umask 可能设置不正确,导致无法检测到 repo 的公钥文件。运行以下命令,然后再次尝试更新您的存储库:sudo chmod a+r /etc/apt/keyrings/docker.gpg.
( _1 y" a" U) u/ g' g/ e0 D```
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|华强北 电脑城 龙岗电子世界 龙华电脑城 pc4g.com ( 粤ICP备16039863号 )

GMT+8, 2024-9-14 17:49 , Processed in 0.162683 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表