Ubuntu安装搭建docker环境
Posted 白-胖-子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu安装搭建docker环境相关的知识,希望对你有一定的参考价值。
开启IP转发
查看是否开启
- docker通讯需要开启ipforward
sysctl -a | grep ipv4forward
net.ipv4.ip_forward = 1
表示开启
开启ipforward
- 没开启的话修改参数把他开启
echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
安装一些工具和依赖包
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
下载密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
添加软件仓库
sudo add-apt-repository \\
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \\
$(lsb_release -cs) \\
stable"
更新仓库
sudo apt-get update
安装docker-ce
sudo apt-get install docker-ce
启动doceker服务
systemctl enable --now
验证是否安装成功
docker info
root@u20-58:/home/u20# docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
scan: Docker Scan (Docker Inc., v0.8.0)
Server:
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 1
Server Version: 20.10.7
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.8.0-48-generic
Operating System: Ubuntu 20.10
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.909GiB
Name: u20-58
ID: 5XG5:337F:AKD5:POKR:KOMK:UUFO:7BPM:TZ7O:E6IS:OXQ7:I5RV:NBBQ
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
以上是关于Ubuntu安装搭建docker环境的主要内容,如果未能解决你的问题,请参考以下文章